Dan Schlosser
Jan 29, 2017 · 2 min read

Passing in Extra Data

Handling the click

// Define a new function
ProgressiveImage.prototype.onClick = function() {
alert(this.myMetadata);
}
// Modify existing function
ProgressiveImage.prototype.getElement = function() {
if (!this.element) {
this.element = document.createElement(
this.pig.settings.figureTagName);
this.element.className = this.classNames.figure;
// Add this line!
this.element.addEventListener('click',
this.onClick.bind(this));
this._updateStyles();
}
return this.element;
};

Performance

    Dan Schlosser

    Written by

    PM @google on @GoogleDrive. Previously @minimill_co, @columbia, @venmo, @facebook. https://schlosser.io

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade