angular-scroll-watch icon indicating copy to clipboard operation
angular-scroll-watch copied to clipboard

sw-broadcast expression cant use && or ||?

Open einsitang opened this issue 9 years ago • 2 comments

I make a function like "load more end" , but when I first enter , that event("load more end") will trigger,this is my code :

let loadMoreEndDefer;
                let loadMoreEndDeger;
               //here is a real function for the app
                $scope.$on('load more end', ($evt, n, locals) =>{
                    // For the "end" button
                    $log.debug('load more...');

                    return;
                    if(!loadMoreEndDefer){

                        loadMoreEndDefer = userListCtrl.loadMoreEnd(20);
                        loadMoreEndDefer['finally'](()=>{
                            loadMoreEndDefer = null;
                        })

                    }

                });
                //here is a test function for debug
                $scope.$on('test',($evt, n, locals)=>{
                    $log.debug($evt,n,locals);
                });

and my view setting like this :

scroll-watch="{from:0,to:-1,stage:'dialog'}"
sw-broadcast="{'load more end':'$progress ==1 && $positive!=-1','test':true}"

when I first enter,I see the console show this log:

load more...   <- here is the 'load more end' event
{$positive: -1, $negative: -1, $progress: 1, $percentage: 100, $direction: 0…}   <= here is the 'test' event

that mean 'load more end':'$progress ==1 && $positive!=-1' cant work ? I try use and even & replace && , but will show me error stack

einsitang avatar Mar 23 '16 03:03 einsitang

I try to change 'load more end':false,'test':true,but the load more end still trigger,look like there is no difference with the test

einsitang avatar Mar 23 '16 04:03 einsitang

Hi @forfuns ,

I tried to recreate the result you described.

$positive: -1

http://plnkr.co/edit/KXFVv8VUUJOtJ4v2oW4X

This is caused by the page not having any scrollbar I guess.

Working demo of $progress == 1 && $positive != -1

http://plnkr.co/edit/uT9TW1wk0AfbmcZOquHB (scroll down and filter the console output with @load1)

  • @load1 log of load more
  • @load2 log of load more end

pc035860 avatar Mar 23 '16 13:03 pc035860