This repository was archived by the owner on Jan 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
Support AMD #41
Open
ethanresnick
wants to merge
3
commits into
Prinzhorn:master
Choose a base branch
from
ethanresnick:amd
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Support AMD #41
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "skrollr-menu-amd", | ||
| "version": "0.1.12", | ||
| "homepage": "https://github.com/ethanresnick/skrollr-menu", | ||
| "authors": [ | ||
| "Ethan Resnick <ethan.resnick@gmail.com>" | ||
| ], | ||
| "main": "dist/skrollr.menu.min.js", | ||
| "license": "MIT", | ||
| "ignore": [ | ||
| "**/.*", | ||
| "node_modules", | ||
| "bower_components", | ||
| "test", | ||
| "tests" | ||
| ] | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't this code executed once I do
require(['skrollr-menu'], function() {})(which means too late)?By the way, where is the name of this module specified? I know nothing about AMD, but looking at Prinzhorn/skrollr#409 I can see that it's defined as
skrollr. I mean, how do you required the menu plugin?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.
Sorry it's taken me a bit to get back to this.
When this code runs will depend on the
requireconfiguration, but there's no reason to assume it will generally run later than the non-AMD setup we have now. In the non-AMD version, it runs only after skrollr has been downloaded and executed (since it must be included before skrollr-menu), and then only after skrollr-menu's been downloaded. In the AMD version, the code will run after the AMD loader's been downloaded and executed, and then after the skrollr-menu module's been downloaded. But it won't have to wait for the skrollr module to donwload (AMD loaders download the resources in parallel) or for the skrollr-menu module to start executing (since this code is defined outside the module body).Perhaps the bigger issue, though, is that the AMD loader won't block the page's rendering. So even if the browser runs the code at about the same time in either case, it may have already shown the rendered page to the user under the AMD version, causing a visible jump as the code scrolls back to the top. The only way to prevent this, I think, would be to put this code in the HTML directly (making sure it's blocking but not taking an extra request) rather than use AMD. A bit annoying, but probably the best solution.
Re the module's name: it actually doesn't need one, and not naming it arguably makes it a bit more flexible. Only the
skrollrmodule needs a hardcoded name, so that the plugins can dependablyrequireit. With the setup in this commit, someone would require skrollr-menu like this:Still, we can give it a name if you want.