javascript - Use Onload on image tag in ember -


i have template in photos being displayed in frame ( each frame different different images) .i have written function uses images original height , width , gives me customized width , height particular frame inorder restore aspect ratio.now have called function through onload images loads on particular moment.

my feed.hbs( template)

<img src = "{{photo.0.photo_url}}" onload = "onimageload(event);" {{action "imgoverlay0" photo}}/> 

function

function onimageload(evt) {      var img = evt.currenttarget;      // what's size of image , it's parent     var w = $(img).width();     var h = $(img).height();     var tw = $(img).parent().width();     var th = $(img).parent().height();      // compute new size , offsets     var result = scaling(w, h, tw, th,false);      // adjust image coordinates , size     img.width = result.width;     img.height = result.height;     $(img).css("margin-left", result.targetleft);     $(img).css("margin-top", result.targettop);     // console.log("result",result)     return result; }  function scaling (w, h, tw, th,false){    //manipulation data  

}

but not included in build of ember have kept function file in bower_compontent.how include in ember app ?

it better put javascript file in vendor directory because bower_components included in .gitignore.

say put code in vendor/file-onload.js.

then import in ember-cli-build.js

app.import('vendor/file-onload.js'); 

it easier if put these functions in corresponding feed controller.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -