zllovesuki / slugsurvival

Source Code for SlugSurvival.com with Cloudflare Workers Site support
https://slugsurvival.com
GNU General Public License v3.0
14 stars 3 forks source link

dom-to-image doesn't work on iOS #17

Open zllovesuki opened 7 years ago

zllovesuki commented 7 years ago

Probably related to tsayen/dom-to-image#74

AvanishKumar008 commented 7 years ago

@zllovesuki In iOS i test same thing. Please use toSvg for iOS. i am using same code for iOS. I am using this code. It's working fine for me.

var node = document.getElementById('game1-screen');

domtoimage.toSvg(node)
    .then(function (dataUrl) {
        var img = new Image();
        img.src = dataUrl;

        var canvas = document.createElement( "canvas" );
        var ctx = canvas.getContext( "2d" );

        canvas.width  = 500;
        canvas.height = 300;

        ctx.drawImage( img, 0, 0);

        document.body.appendChild('<img src="'+canvas.toDataURL( "image/png" )+'" />');
    }

Thanks Avanish Kumar LinkedIn

zllovesuki commented 6 years ago

WebKit and IE blocked .toDataUrl() if you have <foreignObject> in the canvas, which is what dom-to-image has. Still trying to figure out a workaround.

FrankRoc commented 5 years ago

@zllovesuki In iOS i test same thing. Please use toSvg for iOS. i am using same code for iOS. I am using this code. It's working fine for me.

var node = document.getElementById('game1-screen');

domtoimage.toSvg(node)
  .then(function (dataUrl) {
      var img = new Image();
      img.src = dataUrl;

      var canvas = document.createElement( "canvas" );
      var ctx = canvas.getContext( "2d" );

      canvas.width  = 500;
      canvas.height = 300;

      ctx.drawImage( img, 0, 0);

      document.body.appendChild('<img src="'+canvas.toDataURL( "image/png" )+'" />');
  }

Thanks Avanish Kumar LinkedIn

not work when image too large .

zllovesuki commented 5 years ago

@FrankRoc at this point I think we are better off using remote server instead of client html.