Skip to content

Have you thought about using ng-style timeout and some recursion to acomplish this in pure angular? #1

Description

@batoure

i feel like the following code would do 90% of what stretchback does you could probably clean it up into a factory that would take an array of img links and an interval

<body ng-style="changeBack">

<body>

.controller('PageCtrl', function($rootScope, $scope, $timeout, $log) {
        var someImages =    [
                            {'url':'./assets/img/bg/1.jpg'},
                            {'url':'./assets/img/bg/2.jpg'},
                            {'url':'./assets/img/bg/3.jpg'},
                            {'url':'./assets/img/bg/4.jpg'}
                        ];

        var switchBack = function(){
            var num = Math.floor(Math.random()*4)+1;
            $rootScope.changeBack = {
            'background-image' : 'url('+someImages[num].url+')',
            'background-size' :'cover',
            'transition':'background-image 4s'
            };
            ///$log.log(someImages);
            $timeout(switchBack,7000)
        }

        switchBack();

    })

don't get me wrong my css probably needs work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions