• <bdo id='08fQz'></bdo><ul id='08fQz'></ul>
    1. <tfoot id='08fQz'></tfoot>

      1. <legend id='08fQz'><style id='08fQz'><dir id='08fQz'><q id='08fQz'></q></dir></style></legend>

        <i id='08fQz'><tr id='08fQz'><dt id='08fQz'><q id='08fQz'><span id='08fQz'><b id='08fQz'><form id='08fQz'><ins id='08fQz'></ins><ul id='08fQz'></ul><sub id='08fQz'></sub></form><legend id='08fQz'></legend><bdo id='08fQz'><pre id='08fQz'><center id='08fQz'></center></pre></bdo></b><th id='08fQz'></th></span></q></dt></tr></i><div id='08fQz'><tfoot id='08fQz'></tfoot><dl id='08fQz'><fieldset id='08fQz'></fieldset></dl></div>

        <small id='08fQz'></small><noframes id='08fQz'>

      2. 画布响应式媒体屏幕最小宽度 - FabricJS

        Canvas responsive media screen min-width - FabricJS(画布响应式媒体屏幕最小宽度 - FabricJS)

          1. <legend id='sdgeE'><style id='sdgeE'><dir id='sdgeE'><q id='sdgeE'></q></dir></style></legend>
                <bdo id='sdgeE'></bdo><ul id='sdgeE'></ul>
              • <i id='sdgeE'><tr id='sdgeE'><dt id='sdgeE'><q id='sdgeE'><span id='sdgeE'><b id='sdgeE'><form id='sdgeE'><ins id='sdgeE'></ins><ul id='sdgeE'></ul><sub id='sdgeE'></sub></form><legend id='sdgeE'></legend><bdo id='sdgeE'><pre id='sdgeE'><center id='sdgeE'></center></pre></bdo></b><th id='sdgeE'></th></span></q></dt></tr></i><div id='sdgeE'><tfoot id='sdgeE'></tfoot><dl id='sdgeE'><fieldset id='sdgeE'></fieldset></dl></div>
                  <tfoot id='sdgeE'></tfoot>

                  <small id='sdgeE'></small><noframes id='sdgeE'>

                    <tbody id='sdgeE'></tbody>
                  本文介绍了画布响应式媒体屏幕最小宽度 - FabricJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试为每个分辨率调整画布,所以我首先使用 css 并为每个分辨率放置媒体屏幕.

                  I trying adjust canvas for each resolution, so I first using css and put medias screens for each resolution.

                  @media screen and (min-width: 320px) {
                    #c {   -webkit-transform : scale(0.38);
                  -webkit-transform-origin : 0 0; }
                  

                  https://jsfiddle.net/qj3oyzs8/

                  它对我有用,但所有对象都不能正确拖动、调整大小或旋转.一种解决方案是应用 zoomOut 和 zoomIn,例如:

                  It work for me, but all object not drag, resize or rotable properly. One solution is apply zoomOut and zoomIn, eg:

                  http://jsfiddle.net/Q3TMA/662/

                  现在我需要帮助了解如何在浏览器中正确打开画布缩放的捕获分辨率

                  Now I need help for know How capture resolution for open correctly canvas scale in the browser

                  编辑

                  function screencan() {
                     var widthscrencan = (window.innerWidth > 0) ? window.innerWidth : screen.width;
                  
                  /*
                  
                  In if has to have the same scale the css
                  @media screen and (min-width: 320px) {
                    #c {   -webkit-transform : scale(0.38);
                  -webkit-transform-origin : 0 0; }
                  }
                  
                  
                  */
                      if(widthscrencan <= 360 ) {
                             // Zoom Out
                  
                  
                   function zoomOut() {
                          // TODO limit max cavas zoom out
                  
                          canvasScale = canvasScale / SCALE_FACTOR;
                  
                          canvas.setHeight(canvas.getHeight() * (1 / SCALE_FACTOR));
                          canvas.setWidth(canvas.getWidth() * (1 / SCALE_FACTOR));
                  
                          var objects = canvas.getObjects();
                          for (var i in objects) {
                              var scaleX = objects[i].scaleX;
                              var scaleY = objects[i].scaleY;
                              var left = objects[i].left;
                              var top = objects[i].top;
                  
                              var tempScaleX = scaleX * (1 / SCALE_FACTOR);
                              var tempScaleY = scaleY * (1 / SCALE_FACTOR);
                              var tempLeft = left * (1 / SCALE_FACTOR);
                              var tempTop = top * (1 / SCALE_FACTOR);
                  
                              objects[i].scaleX = tempScaleX;
                              objects[i].scaleY = tempScaleY;
                              objects[i].left = tempLeft;
                              objects[i].top = tempTop;
                  
                              objects[i].setCoords();
                          }
                  
                          canvas.renderAll();        
                      }
                  
                      }               
                   }
                   window.onload = screencan;
                  

                  没用

                  感谢您的帮助

                  推荐答案

                  快乐!!!我明白了:D

                  Happy !!! I got it :D

                  唯一的问题是对于新的调整大小的浏览器移动.需要刷新页面,因为 window.onload = zoomIn;

                  The only problem is that for a new resizing the browser move. It will be necessary to refresh the page, because window.onload = zoomIn;

                  解决方案!我删除了 CSS 的查询屏幕并:

                  Solution! I removed queryes screen of the css and:

                  widthscrencan = (window.innerWidth > 0) ? window.innerWidth : screen.width; // capture width screen onload
                  canvasScale = 1; //global  
                  
                     if (widthscrencan <=360){ 
                  
                        function zoomIn() {
                            var SCALE_FACTOR = .37;
                            canvasScale = canvasScale * SCALE_FACTOR;
                  
                        canvas.setHeight(canvas.getHeight() * SCALE_FACTOR);
                        canvas.setWidth(canvas.getWidth() * SCALE_FACTOR);
                  
                        var objects = canvas.getObjects();
                        for (var i in objects) {
                            var scaleX = objects[i].scaleX;
                            var scaleY = objects[i].scaleY;
                            var left = objects[i].left;
                            var top = objects[i].top;
                  
                            var tempScaleX = scaleX * SCALE_FACTOR;
                            var tempScaleY = scaleY * SCALE_FACTOR;
                            var tempLeft = left * SCALE_FACTOR;
                            var tempTop = top * SCALE_FACTOR;
                  
                            objects[i].scaleX = tempScaleX;
                            objects[i].scaleY = tempScaleY;
                            objects[i].left = tempLeft;
                            objects[i].top = tempTop;
                  
                            objects[i].setCoords();
                        }
                  
                  
                        canvas.renderAll();
                        alert(widthscrencan+' function 360'); 
                  
                    }
                  
                     window.onload = zoomIn;
                   }
                  
                  
                  
                  
                  
                  
                     if ((widthscrencan >=361) || (widthscrencan ==768)){ 
                  
                              function zoomIn768() {
                            var SCALE_FACTOR = .45;
                            canvasScale = canvasScale * SCALE_FACTOR;
                  
                            canvas.setHeight(canvas.getHeight() * SCALE_FACTOR);
                            canvas.setWidth(canvas.getWidth() * SCALE_FACTOR);
                  
                            var objects = canvas.getObjects();
                            for (var i in objects) {
                                var scaleX = objects[i].scaleX;
                                var scaleY = objects[i].scaleY;
                                var left = objects[i].left;
                                var top = objects[i].top;
                  
                                var tempScaleX = scaleX * SCALE_FACTOR;
                                var tempScaleY = scaleY * SCALE_FACTOR;
                                var tempLeft = left * SCALE_FACTOR;
                                var tempTop = top * SCALE_FACTOR;
                  
                                objects[i].scaleX = tempScaleX;
                                objects[i].scaleY = tempScaleY;
                                objects[i].left = tempLeft;
                                objects[i].top = tempTop;
                  
                                objects[i].setCoords();
                            }
                  
                  
                            canvas.renderAll();
                            alert(widthscrencan+' function 768'); 
                  
                  
                          }
                            window.onload = zoomIn768;
                      }
                  
                     if ((widthscrencan >=769) || (widthscrencan ==992)){ 
                  
                              function zoomIn992() {
                            var SCALE_FACTOR = .5;
                            canvasScale = canvasScale * SCALE_FACTOR;
                  
                            canvas.setHeight(canvas.getHeight() * SCALE_FACTOR);
                            canvas.setWidth(canvas.getWidth() * SCALE_FACTOR);
                  
                            var objects = canvas.getObjects();
                            for (var i in objects) {
                                var scaleX = objects[i].scaleX;
                                var scaleY = objects[i].scaleY;
                                var left = objects[i].left;
                                var top = objects[i].top;
                  
                                var tempScaleX = scaleX * SCALE_FACTOR;
                                var tempScaleY = scaleY * SCALE_FACTOR;
                                var tempLeft = left * SCALE_FACTOR;
                                var tempTop = top * SCALE_FACTOR;
                  
                                objects[i].scaleX = tempScaleX;
                                objects[i].scaleY = tempScaleY;
                                objects[i].left = tempLeft;
                                objects[i].top = tempTop;
                  
                                objects[i].setCoords();
                            }
                  
                  
                            canvas.renderAll();
                            alert(widthscrencan+' function 992'); 
                  
                  
                          }
                            window.onload = zoomIn992;
                      }
                  
                        if ((widthscrencan >=993) || (widthscrencan ==1200)){ 
                  
                              function zoomIn1200() {
                            var SCALE_FACTOR = .9;
                            canvasScale = canvasScale * SCALE_FACTOR;
                  
                            canvas.setHeight(canvas.getHeight() * SCALE_FACTOR);
                            canvas.setWidth(canvas.getWidth() * SCALE_FACTOR);
                  
                            var objects = canvas.getObjects();
                            for (var i in objects) {
                                var scaleX = objects[i].scaleX;
                                var scaleY = objects[i].scaleY;
                                var left = objects[i].left;
                                var top = objects[i].top;
                  
                                var tempScaleX = scaleX * SCALE_FACTOR;
                                var tempScaleY = scaleY * SCALE_FACTOR;
                                var tempLeft = left * SCALE_FACTOR;
                                var tempTop = top * SCALE_FACTOR;
                  
                                objects[i].scaleX = tempScaleX;
                                objects[i].scaleY = tempScaleY;
                                objects[i].left = tempLeft;
                                objects[i].top = tempTop;
                  
                                objects[i].setCoords();
                            }
                  
                  
                            canvas.renderAll();
                            alert(widthscrencan+' function 1200'); 
                  
                  
                          }
                            window.onload = zoomIn1200;
                      }
                  
                  
                        if (widthscrencan >=1300){ 
                  
                              function zoomIn1300() {
                            var SCALE_FACTOR = 1.01;
                            canvasScale = canvasScale * SCALE_FACTOR;
                  
                            canvas.setHeight(canvas.getHeight() * SCALE_FACTOR);
                            canvas.setWidth(canvas.getWidth() * SCALE_FACTOR);
                  
                            var objects = canvas.getObjects();
                            for (var i in objects) {
                                var scaleX = objects[i].scaleX;
                                var scaleY = objects[i].scaleY;
                                var left = objects[i].left;
                                var top = objects[i].top;
                  
                                var tempScaleX = scaleX * SCALE_FACTOR;
                                var tempScaleY = scaleY * SCALE_FACTOR;
                                var tempLeft = left * SCALE_FACTOR;
                                var tempTop = top * SCALE_FACTOR;
                  
                                objects[i].scaleX = tempScaleX;
                                objects[i].scaleY = tempScaleY;
                                objects[i].left = tempLeft;
                                objects[i].top = tempTop;
                  
                                objects[i].setCoords();
                            }
                  
                  
                            canvas.renderAll();
                            alert(widthscrencan+' function 1300'); 
                  
                  
                          }
                            window.onload = zoomIn1300;
                      }
                  

                  这篇关于画布响应式媒体屏幕最小宽度 - FabricJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How does object-fit work with canvas element?(对象适合如何与画布元素一起使用?)
                  How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)

                  <tfoot id='Tm8eS'></tfoot>
                • <small id='Tm8eS'></small><noframes id='Tm8eS'>

                    <bdo id='Tm8eS'></bdo><ul id='Tm8eS'></ul>
                      <tbody id='Tm8eS'></tbody>

                        <i id='Tm8eS'><tr id='Tm8eS'><dt id='Tm8eS'><q id='Tm8eS'><span id='Tm8eS'><b id='Tm8eS'><form id='Tm8eS'><ins id='Tm8eS'></ins><ul id='Tm8eS'></ul><sub id='Tm8eS'></sub></form><legend id='Tm8eS'></legend><bdo id='Tm8eS'><pre id='Tm8eS'><center id='Tm8eS'></center></pre></bdo></b><th id='Tm8eS'></th></span></q></dt></tr></i><div id='Tm8eS'><tfoot id='Tm8eS'></tfoot><dl id='Tm8eS'><fieldset id='Tm8eS'></fieldset></dl></div>

                          1. <legend id='Tm8eS'><style id='Tm8eS'><dir id='Tm8eS'><q id='Tm8eS'></q></dir></style></legend>