Skip to content
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

Feature/initial module #2

Merged
merged 13 commits into from
Feb 3, 2015
Merged

Feature/initial module #2

merged 13 commits into from
Feb 3, 2015

Conversation

jamesjwarren
Copy link
Member

This PR adds the SkrollrService and snSkorllr directive which load and then initialise the skrollr animation elements. The directive refreshes skrollr when an element with the directive is loaded.

scriptTag.type = "text/javascript";
scriptTag.async = true;
scriptTag.src = "components/skrollr/dist/skrollr.min.js";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why inject the skrollr library tag using javascript? This presumes the person using this directive has the same directory structure as us e.g. has the skrollr lib in app/components/. Also this won't work, even for us, when all the javascript is concatenated and/or minified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh I was concerned about this too. The reason I have used this method is we need to initialise skrollr and directives after it has loaded.

Just including the script in the skrollr is never defined before it is used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Prinzhorn/skrollr#lets-get-serious
You just need to wait till the document loads before initialising your directives. You can use the window.onload event to be sure skrollr is defined. It will only run once all assets e.g. css files, javascript files have been loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh for some reason I had assumed angular ran within window.load anyway so neglected to think of it. Does the trick, cheers.

@jamesjwarren
Copy link
Member Author

I've refactored the skrollr initialisation and added an snSkrollrInit directive which allows one to pass in init options like this:

<body sn-skrollr-init="{ smoothScrolling: true }">
...
</body>

@edoparearyee
Copy link
Collaborator

Instead of using a directive for this why not use a provider?
https://docs.angularjs.org/guide/providers

For example in routeProvider you configure the ngRoute service before the app is run. Providers are perfect for reusable services that require a one time config before the app is run.

@jamesjwarren
Copy link
Member Author

I have now replaced the initialisation directive and service with a provider which enables skrollr to be configured in the angular config phase and initialised within app.run().


var _this = this;

this.init = {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make more sense to call this object config instead of init?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed 👍

@jamesjwarren
Copy link
Member Author

We probably don't need to use the promise library anymore either.

@edoparearyee
Copy link
Collaborator

looks good, i think you just need to fix the build and it will be ready for a release.

Also you may want to start think about writing test to improve code coverage, it should be fairly straight forward though, since this is very small.

(actually ignore that, i meant tests for the thisissoon-frontend)

@edoparearyee
Copy link
Collaborator

Looks good 👍

coveralls seems to be slow, will merge and release once it fixes itself

edoparearyee added a commit that referenced this pull request Feb 3, 2015
@edoparearyee edoparearyee merged commit 94813d4 into develop Feb 3, 2015
@coveralls
Copy link

Coverage Status

Coverage decreased (-50.0%) to 50.0% when pulling 69a750e on feature/initial-module into 4539ba7 on develop.

@jamesjwarren jamesjwarren deleted the feature/initial-module branch February 3, 2015 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants