-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imager 0.1.0 #49
Imager 0.1.0 #49
Conversation
Conflicts: test/unit/core.js
…ternal dollar and tests Conflicts: test/unit/core.js
- initial tests are failing because the old feature is still working (good way to know the old expectation we are going to break) - new tests are not working because basically it's not done yet
- removed Imager `regex` option - implemented simple `{width}` interpolation
- added Imager.transforms to let room to customise things further on - replacing {pixel_ratio} pattern in `data-src` URI
Also made the pixel ratio computation executed once, not every time an image is replaced (because it is not supposed to change within the lifecycle of a page).
- list of authors - licensing - created bower package - made `imager` available for publication in npm (it is relevant to use it to host web component on npm) - created the AUTHOR file for npm authors list
…ternal dollar and tests
And making sure we detach any HTML/Array-like collection.
- moved event setup to init - created dedicated method to register events whenever you want
- JS methods documentation - late warning about a possible `scrollDelay` value set to `0`
Hu hu the fact it is again a 55 commits PR is a nice coincidence 8-) |
pixelRatio: function(value){ | ||
return value === 1 ? '' : '-'+value+'x'; | ||
}, | ||
width: function transformWidth(width, map){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom just wondering if this function needs to be named? It doesn't look like it's used by anything so it could be anonymous right?
@oncletom heya, just ran ❯ npm run test
> imager@0.1.0 test /Users/Code/Imager
> jshint Imager.js && karma start --single-run
INFO [karma]: Karma v0.10.8 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.2 (Mac OS X)]: Connected on socket tY9nEXRUDwGAklr2ONt3
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/A-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 2 of 17 SUCCESS (0 secs / 0.029 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 3 of 17 SUCCESS (0 secs / 0.05 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 4 of 17 SUCCESS (0 secs / 0.071 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 5 of 17 SUCCESS (0 secs / 0.092 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 9 of 17 SUCCESS (0 secs / 0.237 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/B-640.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 10 of 17 SUCCESS (0 secs / 0.259 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/A-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 15 of 17 SUCCESS (0 secs / 0.284 secs)
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/A-320.jpg
WARN [web-server]: 404: /base/Demo%20-%20Grunt/Assets/Images/Generated/C-320.jpg
PhantomJS 1.9.2 (Mac OS X): Executed 17 of 17 SUCCESS (0.715 secs / 0.485 secs) |
@@ -39,10 +60,6 @@ | |||
// Class name to give your resizable images. | |||
className: '', | |||
|
|||
// Regular expression to match against your image endpoint's naming conventions | |||
// e.g. http://yourserver.com/image/horse/400 | |||
regex: RegExp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom I think the only config option missing is the onResize
property. Would you be OK to add that please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you referring to the onResize
from #47?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom I'm referring to the config option onResize
which can optionally be specified when creating a new Imager instance (see: https://github.com/BBC-News/Imager.js/blob/b7b31d795ff9d7a0cb39a9626ca426299007a1d2/README.md#onresize) - just thought that should probably be specified in that code comment block as the other config options are detailed there.
I'm going to add this myself now, but I'll just use what you've already written on the README :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that's true, forgot to add it in the JS comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom I've added this now, see: https://github.com/BBC-News/Imager.js/pull/49/files#diff-b33c92ac11fbf0d3ea67899762af99b7R63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
```js | ||
var imgr = new Imager(); | ||
|
||
$(document).on('load.lowPriority', $.proxy(imgr.registerResizeEvent, imgr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom can you clarify the load.lowPriority
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a fictional event on which someone could hook into to register the resizing event. This was the only idea I had at the time of writing the doc.
However if you think there is an existing DOM event which would be more suitable and relevant to register onto, I'm buying the idea!
var imgr = new Imager(); | ||
|
||
// Using jQuery to set-up the event handling and help keep the correct scope when executing the callback | ||
$(document).on('load.lowPriority', $.proxy(imgr.registerResizeEvent, imgr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oncletom can you clarify the load.lowPriority?
@oncletom I've made some tweaks (see last three commits). There are a couple of outstanding comments I've made (see above). If you could comment back please and then once that's done I'll give a final review and then merge :-) |
@oncletom fixed that typo, whoops! Good spot :-) |
No problem! Also the 404 in the tests are related to the fact they have not been generated by the grunt responsive images task. This is not making the tests failing, just raising a notice. We could either run |
@oncletom I reckon we ship dedicated test images, as it'll mean running the tests will be faster not having to rely on the |
@oncletom regarding |
We'll do that later then. Maybe in the same PR as moving all the demos in a dedicated folder. Regarding the |
@oncletom coolio. I've just updated the event btw |
@oncletom I think this is good to merge now. You happy for me to push the big green button? :-) |
@Integralist oh I appreciate but please do it, I like the symbol and the positive progress as an outcome from my first attempt :-) 👍 |
At last!