IONIC源码分析(一)

本文介绍了Ionic框架中全局变量的定义及版本说明,并详细解析了DelegateService的工作原理及其参数处理过程。同时深入探讨了DomUtil提供的多种实用功能,如requestAnimationFrame、cancelAnimationFrame等方法的实现与兼容性处理。

ionic.js

开篇写博客,可能表述无无序,持续改进中。

 一、开头定义全局变量ionic:

           window.ionic = window.ionic || {};

           window.ionic.view = {};

           window.ionic.version = '1.2.4';

二、定义:ionic.DelegateService

传参为method,处理了如下事情:

判断方法名称不为$getByHandle

      function trueFn() { return true; }  //mark ,这句话不知道为啥这么写

      返回一个方法,该方法最终返回DelegateService的一个实例对象,方法里默认传入参数$log, 不知道哪里来的,暂且认为是angular里面的变量。

三、定义:ionic.DomUtil

      在domUtils下扩展如下方法:

     requestAnimationFrame:处理浏览器兼容后的requestAnimationFrame

     cancelAnimationFrame:处理浏览器兼容后cancelAnimationFrame

     animationFrameThrottle : 暂时未理解,注释里这么描述的

When given a callback, if that callback is called 100 times between animation frames, adding Throttle will make it only run the last of the 100 calls.

     contains:类似于jquery的contains的功能

     getPositionInParent : 类似于jquery的position()的功能

    getOffsetTop : 类似于jquery的offset()的功能

    ready:自认为该方法比jquery的domready好用,判断domReady了,则直接调用requestAnimationFrame方法,否则就往readyCallbacks数组里push进去。

   getTextBounds : 目前解释不出来

  getChildIndex :类似于jquery的index()

  getParentWithClass : 查找当前元素的指定class的父亲,最多只往上找10级。

  getParentOrSelfWithClass:名字取的不错

   rectContains :判断一个点是否在一个rect里

   blurAll :取消所有的聚焦

 cachedAttr: 目前不理解为什么可以这样取值

 cachedStyles :同上


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jone_wan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值