zoukankan      html  css  js  c++  java
  • angular --- s3core移动端项目(三)

    angular.module('myApp')

    .directive('listActive',functon(){

        return {

          restrict:'A',

          scope:{

            listActive:‘@’

          },

          link:function(scope,element){

            element.children().on('click',function(){

              element.find('.'+scope.listActive).removeClass(scope.Active);

              angular.element(this).addClass(scope.listActive)

            })

          }

        }

    })

    .directive('iscrollWrapper',["$window",functon($window){

        return {

          restrict:'E',

          transclude:true,
          templateUrl:'templates/iscroll.tpl.html',

          link:function(scope,element,attr){

            var myScroll;

            function createScroll(){

              var ele = angular.element;

              var pullUp = ele('#pullUp'),

                pullUpLable = pullUp.find('.pullUpLable'),

                pullUpIcon = pullUp.find('.pullUpIcon');

                pullDown = ele('#pullDown'),            

                pullDownLable = pullDown.find('.pullDownLable'),

                pullDownIcon = pullDown.find('.pullDownIcon');

                scroller = ele('#scroller');

                loadingStep = 0;

                textFlag = 0;

              pullDown.hide();

              pullUp.hide();

              //init

              var wrapper = document.getElementById('.iscroll-wrapper');

              if(wrapper){

                myScroll = new IScroll(wrapper,{probeType:2,click:true});

              }

              //高度处理

              var head = ele('.header')[0];

              var foot = ele('.footer')[0];

              var headerwrapper = ele('.wrapper-head')[0];

              var height = $window.innerHeight - (head === undefined ? 0 :head.clientHeight) - (foot === undefined ? 0 :foot.clientHeight) - headerwrapper.clientHeight;

              ele(wrapper).css('min-height',height);

              function setCenter(jqobj){

                var parent = jqobj.parent();

                var width = parent.width();

                var half = width/2;

                var selfhalf = jqobj.width()/2;

                jqobj.css('margin-left',half-selfhalf);

              }

              function setCenter(getAdv){

                var adv= ['深度对接‘,'使用同步‘,'飞速价值','dsad...']

                var index= Math.round(Math.random()*3);

                return adv[index];

              }

              

              //滚动时
              myScroll.on('scroll',function(){
                if (textFlag == 0) {
                  pullDownLable.html(getAdv());
                  textFlag == 1;
                }
                if (loadingStep ==0 && !pullDown.attr('class').match('flip|loading') && !pullUp.attr('class').match('flip|loading')) {
                  if (this.y <20 && this.y>0) {
                    pullDown.hide()
                  }else if (this.y <40 && this.y>20) {
                    //显示字
                    pullDown.show();
                    setCenter(pullDownLable);
                    setCenter(pullDownIcon);
                  }else if (this.y>40) {
                    //下拉刷新效果
                    pullDown.show();
                    setCenter(pullDownLable);
                    setCenter(pullDownIcon);
                    myScroll.refresh();
                    pullDown.addClass('flip');
                    loadingStep = 1;
                  }else if (this.y <this.maxScrollY && this.y>(this.maxScrollY - 35)) {
                    pullDown.hide()
                  }else if (this.y<(this.maxScrollY - 35)) {
                    //下拉刷新效果
                    pullDown.show();
                    setCenter(pullDownLable);
                    setCenter(pullDownIcon);
                    myScroll.refresh();
                    pullDown.addClass('loading');
                    loadingStep = 1;
                  }
                }

              })
              //滚动完毕
              myScroll.on('scrollEnd',function(){
                textFlag = 0;
                if(loadingStep == 1){
                  if (pullUp.attr('class').match(flip|loading)) {
                    pullUp.removeClass('flip').addClass('loading');
                    pullUpAction();
                  }else if (pullDown.attr('class').match(flip|loading)) {
                    pullDown.addClass('loading');
                    pullDownAction();
                  }else{
                    pullDown.slideUp();
                    pullUp.hide();
                  }
                }
              });

              //下拉刷新

              function pullDownAction(){

                pullDown.click();

                setTimeout(function(){

                    pullDown.slideUp('slow');

                    pullDown.attr('class','');

                    ele(scroller).css('min-height',ele(wrapper).height()+1);
                    loadingStep = 0;

                },500)

              };

              function pullUpAction(){

                pullUp.click();

                setTimeout(function(){

                    pullUp.slideUp('slow');

                    pullUp.attr('class','');

                    ele(scroller).css('min-height',ele(wrapper).height()+1);
                    loadingStep = 0;

                },500)

              };

              wrapper.addEventListener('touchmove',function(e){e.preventDefault();},false);

              return myScroll;

            }

            angular.element(document).ready(function(){

              if(!myScroll){

                var myScroll = cresteScroll();

                scope.myScroll = myScroll;

              }

            })

          }

        }

    }])

     1 <div id='icroll-wrapper' ng-modal='myScroll'>
     2     <div id='scroller'>
     3         <div id='pullDown' ng-click='refreashPage()' class=''>
     4             <span class='pullDownLable'></span>
     5             <span class='pullDownIcon'></span>        
     6          </div>
     7         <ul ng-translude ></ul>
     8         <div id='pullUp' ng-click='loadMore()'>
     9             <span class='pullUpLablepullUpIcon'></span>
    10             <span class='pullUpLable'></span>        
    11          </div>        
    12     </div>
    13 </div>
  • 相关阅读:
    堆的创建、优先队列、topk、堆排序C语言实现
    HTTPS加密原理
    go shard map实现
    Python进程间通信
    TCP 半连接队列和全连接队列
    WireShark过滤语法
    TCP拥塞机制
    【企业管理实务系列】低值易耗品管理办法
    CV之Face Change:基于人工智能实现国内众多一线美女明星换脸(基于Face++输出4*106个特征点定位+融合代码、deepfake技术)
    【转发】农行银企直联XML对接socket SAP EPIC
  • 原文地址:https://www.cnblogs.com/peiyao/p/7274000.html
Copyright © 2011-2022 走看看