• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Why is rescaling in standalone web app broken in iOS10?

Explorer ,
May 13, 2019 May 13, 2019

Copy link to clipboard

Copied

Using Animate CC, with publish settings set to make responsive = both, center = both, scale to fill visible area = fit in view, like this:

rescaling.png

In mobile Safari, everything works out well, the canvas resizes as normal when screen orientation changes. When saved to Home Screen as standalone web app though, the canvas isn't resizing after changing to a smaller size, like this:

rescalingscreen.gif

Here's the full html code generated by Animate CC:

<!DOCTYPE html>

<!--

  NOTES:

  1. All tokens are represented by '$' sign in the template.

  2. You can write your code only wherever mentioned.

  3. All occurrences of existing tokens will be replaced by their appropriate values.

  4. Blank lines will be removed automatically.

  5. Remove unnecessary comments before creating your template.

-->

<html>

<head>

<meta charset="UTF-8">

<meta name = "viewport" content = "width=device-width,initial-scale=1" />

<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

<meta name="authoring-tool" content="Adobe_Animate_CC">

<title>testView</title>

<!-- write your code here -->

<style>

  #animation_container {

  position:absolute;

  margin:auto;

  left:0;right:0;

  top:0;bottom:0;

  }

</style>

<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>

<script>

(function (cjs, an) {

var p; // shortcut to reference prototypes

var lib={};var ss={};var img={};

lib.ssMetadata = [];

// symbols:

// stage content:

(lib.testView = function(mode,startPosition,loop) {

  this.initialize(mode,startPosition,loop,{});

}).prototype = p = new cjs.MovieClip();

p.nominalBounds = null;

// library properties:

lib.properties = {

  id: '035086AC98814BD6A0BA64225202ABA0',

  width: 400,

  height: 550,

  fps: 24,

  color: "#3366FF",

  opacity: 1.00,

  manifest: [],

  preloads: []

};

// bootstrap callback support:

(lib.Stage = function(canvas) {

  createjs.Stage.call(this, canvas);

}).prototype = p = new createjs.Stage();

p.setAutoPlay = function(autoPlay) {

  this.tickEnabled = autoPlay;

}

p.play = function() { this.tickEnabled = true; this.getChildAt(0).gotoAndPlay(this.getTimelinePosition()) }

p.stop = function(ms) { if(ms) this.seek(ms); this.tickEnabled = false; }

p.seek = function(ms) { this.tickEnabled = true; this.getChildAt(0).gotoAndStop(lib.properties.fps * ms / 1000); }

p.getDuration = function() { return this.getChildAt(0).totalFrames / lib.properties.fps * 1000; }

p.getTimelinePosition = function() { return this.getChildAt(0).currentFrame / lib.properties.fps * 1000; }

an.bootcompsLoaded = an.bootcompsLoaded || [];

if(!an.bootstrapListeners) {

  an.bootstrapListeners=[];

}

an.bootstrapCallback=function(fnCallback) {

  an.bootstrapListeners.push(fnCallback);

  if(an.bootcompsLoaded.length > 0) {

  for(var i=0; i<an.bootcompsLoaded.length; ++i) {

  fnCallback(an.bootcompsLoaded);

  }

  }

};

an.compositions = an.compositions || {};

an.compositions['035086AC98814BD6A0BA64225202ABA0'] = {

  getStage: function() { return exportRoot.getStage(); },

  getLibrary: function() { return lib; },

  getSpriteSheet: function() { return ss; },

  getImages: function() { return img; }

};

an.compositionLoaded = function(id) {

  an.bootcompsLoaded.push(id);

  for(var j=0; j<an.bootstrapListeners.length; j++) {

  an.bootstrapListeners(id);

  }

}

an.getComposition = function(id) {

  return an.compositions[id];

}

})(createjs = createjs||{}, AdobeAn = AdobeAn||{});

var createjs, AdobeAn;

</script>

<script>

var canvas, stage, exportRoot, anim_container, dom_overlay_container, fnStartAnimation;

function init() {

  canvas = document.getElementById("canvas");

  anim_container = document.getElementById("animation_container");

  dom_overlay_container = document.getElementById("dom_overlay_container");

  var comp=AdobeAn.getComposition("035086AC98814BD6A0BA64225202ABA0");

  var lib=comp.getLibrary();

  handleComplete({},comp);

}

function handleComplete(evt,comp) {

  //This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.

  var lib=comp.getLibrary();

  var ss=comp.getSpriteSheet();

  exportRoot = new lib.testView();

  stage = new lib.Stage(canvas);

  //Registers the "tick" event listener.

  fnStartAnimation = function() {

  stage.addChild(exportRoot);

  createjs.Ticker.setFPS(lib.properties.fps);

  createjs.Ticker.addEventListener("tick", stage);

  }   

  //Code to support hidpi screens and responsive scaling.

  function makeResponsive(isResp, respDim, isScale, scaleType) {

  var lastW, lastH, lastS=1;

  window.addEventListener('resize', resizeCanvas);

  resizeCanvas();

  function resizeCanvas() {

  var w = lib.properties.width, h = lib.properties.height;

  var iw = window.innerWidth, ih=window.innerHeight;

  var pRatio = window.devicePixelRatio || 1, xRatio=iw/w, yRatio=ih/h, sRatio=1;

  if(isResp) {               

  if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {                   

  sRatio = lastS;               

  }

  else if(!isScale) {

  if(iw<w || ih<h)

  sRatio = Math.min(xRatio, yRatio);

  }

  else if(scaleType==1) {

  sRatio = Math.min(xRatio, yRatio);

  }

  else if(scaleType==2) {

  sRatio = Math.max(xRatio, yRatio);

  }

  }

  canvas.width = w*pRatio*sRatio;

  canvas.height = h*pRatio*sRatio;

  canvas.style.width = dom_overlay_container.style.width = anim_container.style.width =  w*sRatio+'px';

  canvas.style.height = anim_container.style.height = dom_overlay_container.style.height = h*sRatio+'px';

  stage.scaleX = pRatio*sRatio;

  stage.scaleY = pRatio*sRatio;

  lastW = iw; lastH = ih; lastS = sRatio;           

  stage.tickOnUpdate = false;           

  stage.update();           

  stage.tickOnUpdate = true;

  }

  }

  makeResponsive(true,'both',true,1);

  AdobeAn.compositionLoaded(lib.properties.id);

  fnStartAnimation();

}

</script>

<!-- write your code here -->

</head>

<body onload="init();" style="margin:0px;">

  <div id="animation_container" style="background-color:rgba(51, 102, 255, 1.00); width:400px; height:550px">

  <canvas id="canvas" width="400" height="550" style="position: absolute; display: block; background-color:rgba(51, 102, 255, 1.00);"></canvas>

  <div id="dom_overlay_container" style="pointer-events:none; overflow:hidden; width:400px; height:550px; position: absolute; left: 0px; top: 0px; display: block;">

  </div>

  </div>

</body>

</html>

On an iOS9 device, it seems to be working well. How to do update Animate CC's rescaling code so that it works in iOS10 (and above)?

Views

298

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 16, 2019 May 16, 2019

Copy link to clipboard

Copied

Strangely enough, when I added this code, and my iOS device has that blue header (for personal hotspot), the standalone web app scales back bigger as normal when the screen orientation changes. It only works in hotspot mode though.

window.addEventListener("orientationchange", function () {

     document.width = window.screen.width;

     });

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 26, 2019 May 26, 2019

Copy link to clipboard

Copied

LATEST

Anyone knows the fix to this bug in the responsive code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines