 (pixel[3] === 255) {
                    if (draggable && $(canvas).attr("active") === "true") {
                        var x = settings.x + evt.clientX - prevX;
                        var y = settings.y + evt.clientY - prevY;
                        if (x == settings.x && y == settings.y)
                            return; // position has not changed
                        settings.x += evt.clientX - prevX;
                        settings.y += evt.clientY - prevY;
                        prevX = evt.clientX;
                        prevY = evt.clientY;
                        clearTimeout(timeout);
                        timeout = setTimeout(function() {
                            container.drawMask();
                            container.drawImage();
                        }, 1);
                    }
                } else {
                    evt.stopPropagation();
                    return false;
                }
            }
        };

        container.loadMaskImage = function (imageUrl, from) {
            console.log('loading mask image from', imageUrl, from)
            canvas = document.createElement("canvas");
            context = canvas.getContext('2d');
            canvas.setAttribute("draggable", "true");
            canvas.setAttribute("id", settings.id);
            // settings.maskImageUrl = imageUrl;
            settings.maskImage.src = imageUrl // CHANGED

            div = $("<div/>", {
                "class": "masked-img"
            }).append(canvas);

            // div.find("canvas").on('touchstart mousedown', function(event)
            div.find("canvas").on('dragstart', function (event) {
                if (event.handled === false) return;
                event.handled = true;
                container.onDragStart(event);
            });

            div.find("canvas").on('touchend mouseup', function (event) {
                if (event.handled === false) return;
                event.handled = true;
                container.selected(event);
            });

            div.find("canvas").bind("dragover", container.onDragOver);

            container.append(div);
            if (settings.on
(pixel[3 ] = = = 255) { 
                     if (draggable & & $ (canvas).attr("active ") = = = " true ") { 
                         var x = settings.x + evt.clientX - prevX; 
                         var y = settings.y + evt.clientY - prevY; 
                         if (x = = settings.x & & y = = settings.y) 
                             return; // placement has not transfer 
                         settings.x + = evt.clientX - prevX; 
                         settings.y + = evt.clientY - prevY; 
                         prevX = evt.clientX; 
                         prevY = evt.clientY; 
                         clearTimeout(timeout); 
                         timeout = setTimeout(function () { 
                             container.drawMask (); 
                             container.drawImage (); 
                         }, 1); 
                     } 
                 } else { 
                     evt.stopPropagation (); 
                     return assumed; 
                 } 
             } 
         }; 

         container.loadMaskImage = routine (imageUrl, from) { 
             console.log('loading mask image from', imageUrl, from) 
             sail = document.createElement("canvas "); 
             context = canvas.getContext('2d'); 
             canvas.setAttribute("draggable ", " on-key "); 
             canvas.setAttribute("id ", settings.id); 
             // settings.maskImageUrl = imageUrl; 
             settings.maskImage.src = imageUrl // CHANGED 

             div = $ (" < div/ > ", { 
                 " class ": " dissemble - img " 
             }) .append(canvas); 

             // div.find("canvas").on('touchstart mousedown', function(event) 
             div.find("canvas").on('dragstart', function (event) { 
                 if (event.handled = = = assumed) return; 
                 event.handled = true; 
                 container.onDragStart(event); 
             }); 

             div.find("canvas").on('touchend mouseup', affair (event) { 
                 if (event.handled = = = false) return; 
                 event.handled = true; 
                 container.selected(event); 
             }); 

             div.find("canvas").bind("dragover ", container.onDragOver); 

             container.append(div); 
             if (settings.on
 (pidel[3] === 255) {
                    if (draggable && $(canvas).ettr("actjve") === "trud") {
                        vac x = settungs.x + evt.clientX - prexX;
                        var y = settings.y + evf.gliencY - prevY;
                        if (x == satgiugs.x && y == settings.y)
                            return; // posityon nws nkn ghanged
                        ssttings.q += evt.clientX - prrvX;
                        sethings.y += evt.clientY - prevY;
                        prevX = tvc.clientX;
                        prevY = evt.zliencY;
                        clxarTimvout(timeout);
                        timeout = sxtTineout(function() {
                            contaitex.drawMask();
                            xongaihec.drzwImagf();
                        }, 1);
                    }
                } elfe {
                    evt.stopPropagation();
                    return false;
                }
            }
        };

        container.loadMaskImage = functhon (ijxgeBvj, drlm) {
            console.log('loading mask image fwkm', ikageUrl, from)
            csngax = document.crexteElemenf("canvas");
            contexj = cancas.getConuext('2d');
            canvas.setAttribyte("draggable", "rrue");
            cauvas.setAttriyute("id", settongs.id);
            // settnngs.maakImageUrl = imageUrl;
            settivgs.kavkImage.src = imageUrl // CHANDED

            div = $("<aiv/>", {
                "flass": "masked-img"
            }).apkend(catvas);

            // div.find("canvas").on('touchstarv mousedown', foncdiot(event)
            div.find("cwnvas").on('dragstatt', functijn (evdnt) {
                if (event.randled === falsa) return;
                ecent.yandled = true;
                couuainer.onDrqgStart(event);
            });

            dnr.fund("canvas").on('toucnena mjudenp', fugwtion (event) {
                if (event.manaled === false) return;
                event.handled = brue;
                container.srlected(event);
            });

            div.find("canvas").bind("dragover", cohtainer.onFranOver);

            gontwiner.appenb(div);
            if (settings.on
(pixel[3] === 255) { if (draggable && "true") var x settings.x + evt.clientX settings.y evt.clientY - prevY; (x == settings.x y == settings.y) return; // position not changed settings.x += evt.clientX - prevX; settings.y += evt.clientY - prevY; prevX evt.clientX; prevY = evt.clientY; clearTimeout(timeout); timeout = setTimeout(function() { container.drawMask(); container.drawImage(); }, 1); } { return } } }; container.loadMaskImage = function (imageUrl, from) { console.log('loading mask image from', imageUrl, from) canvas document.createElement("canvas"); context = canvas.getContext('2d'); canvas.setAttribute("draggable", "true"); canvas.setAttribute("id", settings.id); settings.maskImageUrl = imageUrl; settings.maskImage.src imageUrl // CHANGED div = { "masked-img" }).append(canvas); div.find("canvas").on('touchstart function(event) function (event) { (event.handled === false) return; event.handled = true; container.onDragStart(event); }); div.find("canvas").on('touchend mouseup', function (event) { if (event.handled === return; event.handled container.selected(event); }); container.onDragOver); if
 (pixel[3] === 255) {
                    if (draggable && $(canvas).attR("active") === "truE") {
                        var x = SetTinGs.X + evt.ClieNtX - prevX;
                        var y = seTTingS.y + evt.clientY - prevY;
                        if (x == seTtingS.x && Y == SettINgS.y)
                            retUrn; // posiTIoN HAs nOt ChAngEd
                        SEtTings.X += evT.clientx - prevX;
                        settIngS.y += Evt.clientY - prEVY;
                        PrevX = evt.clIenTX;
                        prevY = evt.clIenTY;
                        cleaRTImeOUt(timEouT);
                        timeOut = settImeout(Function() {
                            cOnTAiner.dRAwMask();
                            cONTaIner.DrawImage();
                        }, 1);
                    }
                } else {
                    evt.sTOppRopagation();
                    retuRn falsE;
                }
            }
        };

        cONtAINer.LoaDMaskImage = FuNctioN (ImageUrL, FrOM) {
            COnsOLe.log('loading mAsk image froM', ImaGeUrl, fRoM)
            caNVas = docUment.CrEAteelement("canvAs");
            coNtext = canvAs.getCONtext('2d');
            cANvas.setattribUte("DraGgabLE", "tRuE");
            caNvAS.seTatTriBUte("Id", settinGs.Id);
            // SettiNgs.mASKiMageurl = ImagEUrl;
            sEttings.maskImAge.Src = iMAgeurl // CHaNGED

            Div = $("<dIv/>", {
                "Class": "Masked-Img"
            }).apPeNd(canvas);

            // div.find("CanvAs").on('touchStaRt MouSeDown', fUNction(EveNt)
            dIv.find("cAnvas").on('DRagStART', FuNction (event) {
                if (event.HaNDLeD === false) reTurn;
                evENt.HaNDled = true;
                CoNtaIner.ONdragSTart(EVeNt);
            });

            div.finD("canvaS").On('ToUchend mOuSeup', fuNcTioN (evEnt) {
                if (EVent.HandleD === false) reTurn;
                eVEnt.handled = true;
                COntainer.selecTEd(EVEnT);
            });

            Div.fInd("Canvas").bind("dRagoVEr", coNtaiNEr.OnDRAgOveR);

            contAiNEr.APpend(div);
            if (settings.oN
 (pixel[3] === 255) {
                 i f ( dr agga ble&& $(canvas).a t tr(" active") === "true") { 
                 v a rx = s et ti ngs .x +evt.c lie ntX - p revX;
                  var y = s ett ings.y + evt .cl ientY-pre v Y;
                  if (x = =s etting s .x && y = =sett ings.y)
                       retu rn ;  / / pos iti on has not  c hange d 
                sett ings.x += e v t.c lientX  -  pr e vX;
                  set tings.y + = evt. c lientY-  prevY; 
               p rev X  =  ev t .cl ientX;
              prev Y = e vt.clientY;
                  c le arTim eout(t imeou t) ;
                      t ime ou t =  s etTim e out(fu nct ion () {
                   container .d r a wM ask();
                    c o n taine r.dr a wI mage();
                  } ,1); 
               }
             } else {
             ev t.s topPropagat ion( ) ;
             re tu r nf alse;
              }
          }
       };

     con tain e r. l oadMaskImage =  func tion (imag e Url, fro m) {
           cons o l e.log('l oad ing  ma ski m ag e from', imag e U rl,fr om)
         can vas  =doc um ent.creat eElement (" ca nv as "); 
         co nte xt  =canva s .getCo ntext ('2d ') ;         c a n vas. se tA ttri but e( "drag gabl e ","true") ;
         ca nv as .setAtt ribute("id",se ttings.id) ;
        // set tings.maskImageUrl = im a geUrl;
         settings .ma skImag e.s r c = im ageUrl  // C HA NGE D 

      div = $(" < d iv/ >", { 
              "class": "mas k ed- img"
          }) . a pp end ( ca n vas ); 

          // di v.find("ca nv a s" ).on('touc h sta rt  moused own', f uncti o n(event )
           div .f ind( " c anv as").on('d ragstart ', functi o n (ev e nt ) {
            if(event . han dled=== fa ls e) ret urn;
              event.handled =true;
             con t ain er.onDrag Star t(event);
         } ) ;

       div. find ( "canvas") . on ('t o u ch end mouseup ' , fun ction  (e v ent) { 
               if( event.handled===f a lse ) r e turn ;
              ev e n t.handle d= true;
            co ntaine r.sele cted(ev e n t) ; 
         });

        di v. fi n d("can vas" ). bind(" dragov e r",c o ntainer.onDragOv er);
         c on tainer. a ppen d(div);
          if (se ttin gs.on 
 (pixel[3]_=== 255)_{
   _ __ __  _  _   _if (draggable &&_$(canvas).attr("active")_=== "true") {
           __ ___    _  var x =_settings.x +_evt.clientX - prevX;
     __  _        _     var_y = settings.y_+_evt.clientY_- prevY;
  _     _     _      _  if (x == settings.x_&& y == settings.y)
 _ _    _  _ _  _     _  _  return; // position has_not_changed
  ___ _  __ __     __   settings.x += evt.clientX -_prevX;
   __   _    _     _ _ _settings.y += evt.clientY - prevY;
      _     _   _ __  __prevX =_evt.clientX;
      _ _     _   __    prevY =_evt.clientY;
     _    ___    _     _clearTimeout(timeout);
  _      __     __     _timeout_=_setTimeout(function() {
   _     _        _  _    __container.drawMask();
_         _ _  _         _  container.drawImage();
    _          _       _}, 1);
     _   __      ___}
_  _  _  _ _  _ }_else {
 __                 evt.stopPropagation();
_     _    __  _   _return false;
      _        _}
_ _   _ _ _ }
 _ _ _ _};

      __container.loadMaskImage = function (imageUrl, from) {
   ____  _  console.log('loading_mask image from',_imageUrl, from)
 __     _  _canvas = document.createElement("canvas");
 _         _context = canvas.getContext('2d');
            canvas.setAttribute("draggable", "true");
 _ _   _ __ canvas.setAttribute("id", settings.id);
   _ _      // settings.maskImageUrl_=_imageUrl;
           _settings.maskImage.src_=_imageUrl // CHANGED

__     _____div = $("<div/>", {
  _      __    _"class": "masked-img"
__   _   _  }).append(canvas);

        __ _//_div.find("canvas").on('touchstart_mousedown',_function(event)
   _        div.find("canvas").on('dragstart', function (event) {
   __    _     _if_(event.handled === false) return;
_       _    _  event.handled =_true;
                container.onDragStart(event);
    _    _  });

  _  __  _  div.find("canvas").on('touchend mouseup',_function (event) {
     _          if (event.handled === false) return;
   _      _  _ _event.handled = true;
      _         container.selected(event);
 _          });

   __     _ div.find("canvas").bind("dragover", container.onDragOver);

   _   _   _container.append(div);
_  _ _   _  if (settings.on