Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

angular wrapper #9

Closed
elgs opened this issue Nov 12, 2013 · 2 comments
Closed

angular wrapper #9

elgs opened this issue Nov 12, 2013 · 2 comments

Comments

@elgs
Copy link

elgs commented Nov 12, 2013

I have written a super simple angular wrapper directive. I think this might be helpful for angular guys.
angular.onscreen.js

(function () {
    angular.module('on-screen', []).directive('onScreen', function () {
        return {
            restrict: 'A',
            link: function (scope, el, attrs) {
                el.onScreen(scope.onScreen);
            }
        };
    });
})();

And here's how you use it:

<html data-ng-app="main-app">
...
<div on-screen="onScreen">I'm here!</div>
<script>
(function () {
    var app = angular.module('main-app', ['on-screen']);
    app.controller('main-control', function ($scope) {
        $scope.onScreen = {
            container: window,
            direction: 'vertical',
            doIn: function () {
                console.log('I am in.');
            },
            doOut: function () {
                console.log('I am out.');
            },
            tolerance: 0,
            throttle: 50,
            toggleClass: 'onScreen',
            lazyAttr: null,
            lazyPlaceholder: 'someImage.jpg',
            debug: false
        };
    });
})();
</script>
...
</html>
@silvestreh
Copy link
Owner

I'm sorry, but I'm unfamiliar with Angular. Is this something you wish to see implemented in the plugin? If so, feel free to fork it and improve it as much as you wish :-)

@elgs
Copy link
Author

elgs commented Nov 12, 2013

Thanks @silvestreh for the answer, and thank you for the awesome onscreen code. :-)

@elgs elgs closed this as completed Nov 12, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants