JavaScript Use Onload on image tag in ember

I have a template in which photos are being displayed in a frame ( each frame is different for different images) .I have written a function which uses the images original height and width and gives me customized width and height for that particular frame inorder to restore the aspect ratio.Now I have called that function through onload as images loads on that 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 the size of this image and it's parent
    var w = $(img).width();
    var h = $(img).height();
    var tw = $(img).parent().width();
    var th = $(img).parent().height();

    // compute the new size and offsets
    var result = scaling(w, h, tw, th,false);

    // adjust the image coordinates and 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 with data 
}

But it will not be included in the build of ember as I have kept the function file in bower_compontent.How do I include it in my ember app ?

Answer:1

It will be better to put this javascript file in vendor directory because normally bower_components is included in .gitignore.

Say you put this code in vendor/file-onload.js.

Then do a import in ember-cli-build.js

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

It will be even easier if you put these functions in corresponding feed controller.

Answer:2

what i need is, When i click on button "Click", the Column "Delete" Should be visible and editable. and when i click on the same button "click" again, the delete column should slide right and hide ...

what i need is, When i click on button "Click", the Column "Delete" Should be visible and editable. and when i click on the same button "click" again, the delete column should slide right and hide ...

  1. show hide div sliding effect

What is this code doing? How is it executing? What is x equal to? Another useful type of higher-order function modifies the function value it is given: function negate(func) { return function(x) { ...

What is this code doing? How is it executing? What is x equal to? Another useful type of higher-order function modifies the function value it is given: function negate(func) { return function(x) { ...

  1. does this function have an inverse
  2. does this function converge
  3. does this function have an inverse calculator
  4. does this function have a maximum or a minimum
  5. does this function converge or diverge
  6. what does this function mean
  7. does function of beauty work
  8. does function of beauty actually work
  9. does function of beauty really work
  10. does function of beauty contain silicones
  11. does function of beauty have silicones
  12. does function
  13. does function have vertical asymptote
  14. does function mean in math

I'm not even sure if this is possible but I want to get the height of the contents in a container. Let's assume I have <div id="container" style="min-height:100vh"> <div class="child">...

I'm not even sure if this is possible but I want to get the height of the contents in a container. Let's assume I have <div id="container" style="min-height:100vh"> <div class="child">...

  1. jquery height of div contents
  2. jquery get iframe contents height
  3. jquery get height of contents
  4. jquery contents height
  5. iframe content height jquery

I've been battling with this for hours now and read several threads on SO and other places, but have hit a dead end. I am trying to scrape a web page and one of the items I need is a text file that is ...

I've been battling with this for hours now and read several threads on SO and other places, but have hit a dead end. I am trying to scrape a web page and one of the items I need is a text file that is ...

  1. text file download
  2. downloading text file java
  3. downloading a text file from a website
  4. curl downloading text file
  5. android download text file
  6. pdf downloading as text file
  7. video downloading as text file
  8. content type for downloading text file