移动端 touch事件 获取当前滑动所在坐标的位置

event.originalEvent.changedTouches[0].pageX event.originalEvent.changedTouches[0].pageY 在touch-start方法中 获取 初始位置 touch-end 事件中获取结束位置。 位置X 坐标和 Y 坐标相减就能知道滑动距离和方向了 touch-move 事件中客户获取实时位置 Model.prototype.div1Touchstart = function(event){ this.xs = event.originalEvent.changedTouches[0].pageX; //debugger; }; Model.prototype.div1Touchend = function(event){ this.xe = event.originalEvent.changedTouches[0].pageX; alert(this.xe - this.xs); };

滚动事件中控制头部换换变化显示的样式

参考:类似于仿途牛:/UI2/demo/tuniu/index_main.w onload事件中实现的效果! //页面初始化 Model.prototype.modelLoad = function(event){ //页面下拉时页头显示背景颜色 var _this=this; $(this.comp("homeContent").domNode).scroll(function() { if($(this).scrollTop()>100){ $(".x-titlebar", _this.getRootNode()).css({"background-color":"rgba(0,0,0,0.8)"}); } else { $(".x-titlebar", _this.getRootNode()).css({"background-color":"rgba(0,0,0,0)"}); } }); };

css编译出错问题 ,报错:Ignoring the whole rule.

报错:Ignoring the whole rule.  一般都是css编译出错了!!删除一部分自定义 css,找下原因,或者css从外部引入 Error in pseudo class or element. (Invalid token "{". Was expecting one of: <IDENT>, ":", <FUNCTION_NOT>, <FUNCTION_LANG>, <FUNCTION>.) Error in attribute selector. (Invalid token "SafMob". Was expecting one [...]

登录页面的实现思路

需求1:要求启动APP 必须先登录。启动APP 如果已经登录过了,就不显示登录页! 直接显示主页! 如果还没登录,就显示登录页,以及切换到注册等。。 因为wex5开发的功能是单页应用!比如仿淘宝,在index.w中 contens下 content 放置一个windowContainer 组件,作为主页!!,每次启动APP都是优先显示主页的!如果想要做的直接打开登录页,不优先访问主页,就需要将content删除掉!index.w中contents 下是空的!什么都不要放!! 思路 在onload事件中判断localStorage 中是否有用户信息,(可以参考:/UI2/demo/netease/index.js) 如果有则直接跳转到主页:justep.Shell.showPage("main"); 如果没有用户信息,就弹出一个windowDialog 显示登录页!登录后,在windowDialog的onReceive 事件中再跳转到主页:justep.Shell.showPage("main");! windowDialog 组件的routable 属性设置为false ,可以防止回退到登录页!这样就只能打开不能路由回去了! 注册页面也可以放置在windowDialog 中,使用contents组件切换显示登录和注册页面即可!! 登录后可以将用户信息放置公共的KO 对象中,这样每个页面都能获取用户信息了!:http://docs.wex5.com/wex5-ui-question-list-2096   (注意:第一次Shell.showPage跳转的页面就是主页,所以登录页才不要使用showPage打开!!否则它就是主页了不符合需求!所以使用windowDialog!!!)   需求2:app启动后,直接访问主页,不需要必须登录。只有打开某些页面的时候才做判断是否登录,也可以 思路 也可以在index.w门户中放置一个windowDialog 作为登录页!和‘需求1’ 的思路是一样的! 每一个shell.showPage [...]

input和button 组合显示案例

参考外码案例/UI2/takeout/index.w 调整按钮和input 的前后顺序 <div class="input-group" component="$UI/system/components/bootstrap/inputGroup/inputGroup" xid="inputGroup1"> <div class="input-group-btn" xid="div7"> <a component="$UI/system/components/justep/button/button" class="btn btn-link" xid="button1" onClick="locationClick" icon="linear linear-book"> <i xid="i15" class="linear linear-book"/> <span xid="span20"></span> </a> </div> <input type="text" class="form-control" component="$UI/system/components/justep/input/input" xid="input4" bind-ref='$model.userData.ref("fAddress")'/> </div> [...]