homerjam / angular-scroll-magic

An angular directive for ScrollMagic, define pins and tweens in markup
http://homerjam.github.io/angular-scroll-magic/
MIT License
18 stars 6 forks source link

angular-scroll-magic

An angular directive for ScrollWizardry, define pins and tweens in markup

Demo

http://homerjam.github.io/angular-scroll-magic/

Changelog

Installation

  1. Install via npm npm i -S angular-scroll-magic

  2. Include the necessary files and dependencies (ScrollWizardry, GSAP) on your page or in your build process

  3. Add hj.scrollMagic to app's module dependencies

Usage

Turn on indicators to help during development

// In your app config
scrollMagicProvider.addIndicators = true;

smScene

Create a scene, by applying the sm-scene directive this determines the timing for the desired behaviour

<div sm-scene="sceneId" duration="500" offset="100" trigger-hook="0.75"></div>

smTween

<div sm-tween="sceneId" duration="1" from-vars="{left: '100%'}" to-vars="{left: '0%'}"></div>

smClassToggle

<div sm-class-toggle="sceneId" classes=""></div>

smPin

<div sm-pin="sceneId"></div>

ScrollMagicService

Allows access to scenes from your controllers.

<!-- Define scene in your template -->
<div sm-scene="'myScene'"></div>
// Add an observer which will trigger on initialisation of the scene
ScrollMagicService.onSceneAdded('myScene', function(scene) {
    // do stuff with `scene`
});

// Or after initialisation
var scene = ScrollMagicService.getScene('myScene');