zepto

How to test for mobile webkit

Deadly 提交于 2019-12-03 10:04:12
问题 I'm looking to build a new website and want to take a responsible "mobile-first" approach. One tenet of this methodology is to only load what you need, and to avoid including large wasteful libraries and frameworks until you actually need them. For this I intend to use modernizr2 to test for features and then load only required files and libraries. On the javascript side, I'm really interested in using something like zepto.js (http://zeptojs.com/) which is a tiny javascript library (2-5k)

What's the Zepto equivalent of jQuery.getScript()?

亡梦爱人 提交于 2019-12-03 08:55:31
What's the Zepto equivalent of jQuery.getScript()? I need to dynamically load a JavaScript file with both libraries. Kris Erickson This works appended to zepto.js! ;(function ($) { $.getScript = function(src, func) { var script = document.createElement('script'); script.async = "async"; script.src = src; if (func) { script.onload = func; } document.getElementsByTagName("head")[0].appendChild( script ); } })($) Torsten Walter ;(function($){ $.getScript = function (url, success, error) { var script = document.createElement("script"), $script = $(script); script.src = url; $("head").append(script

jQuery pluggin -> Zepto; $.fn.extend is undefined

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to zepto, and am using it as a jQuery replacement for the mobile part of a website. So zepto doesn't have $.fn.extend. Fine that's cool with me, but I need my pluggin to work regardless of jquery or zepto. What is zepto's alterative to fn.extend? How would you go about making a cross library extension? I've yet to find any documentation on this. $.fn.extend({ lineRedNAddClass : function(option){ $(this).css('border','red 1px solid').addClass(option); } }); can this be made to work with both from the same script? 回答1: Zepto's extend

How to include external file with webpack

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to include external file with webpack (outside the context) and make the file included in built output bundle.js? consider this setup where "sub-app" is context for webpack: /sub-app/entry.js /bower-components/zepto/zepto.js And webpack config with broccoli: var webpackify = require('broccoli-webpack'); var path = require('path'); var webpack = require("webpack"); var bundler = webpackify(path.resolve('sub-app'), { entry: './entry', output: {filename: './bundle.js'}, devtool: 'eval', module: { loaders: [ {test: /\.js$/, loader

读zepto源码之工具函数

匿名 (未验证) 提交于 2019-12-03 00:39:02
Zepto 提供了丰富的工具函数,下面来一一解读。 本文阅读的源码为 zepto1.2.0 $.extend $.extend 方法可以用来扩展目标对象的属性。目标对象的同名属性会被源对象的属性覆盖。 $.extend 其实调用的是内部方法 extend , 所以我们先看看内部方法 extend 的具体实现。 function extend(target, source, deep) { for (key in source) // 遍历源对象的属性值 if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { // 如果为深度复制,并且源对象的属性值为纯粹对象或者数组 if (isPlainObject(source[key]) && !isPlainObject(target[key])) // 如果为纯粹对象 target[key] = {} // 如果源对象的属性值为纯粹对象,并且目标对象对应的属性值不为纯粹对象,则将目标对象对应的属性值置为空对象 if (isArray(source[key]) && !isArray(target[key])) // 如果源对象的属性值为数组,并且目标对象对应的属性值不为数组,则将目标对象对应的属性值置为空数组 target[key] = [] extend

How to test for mobile webkit

我是研究僧i 提交于 2019-12-03 00:33:38
I'm looking to build a new website and want to take a responsible "mobile-first" approach. One tenet of this methodology is to only load what you need, and to avoid including large wasteful libraries and frameworks until you actually need them. For this I intend to use modernizr2 to test for features and then load only required files and libraries. On the javascript side, I'm really interested in using something like zepto.js ( http://zeptojs.com/ ) which is a tiny javascript library (2-5k) optimized for mobile webkit (and mobile webkit alone) while maintaining a jquery compatible syntax. It's

移动端click延迟和tap事件

匿名 (未验证) 提交于 2019-12-02 21:53:52
一、click等事件在移动端的延迟 click事件在移动端和pc端均可以触发,但是在移动端有延迟现象。 1、背景 由于早期移动设备浏览网页时内容较小,为了增强用户体验,苹果公司专门为移动设备设计了 双击放大 的功能,以确保用户可以方便地放大网页内容,但是当用户单击按钮的时候,移动设备需要延迟 Լ300ms 执行,以判断用户是否是要双击。 2、验证 下面通过js代码来直观地验证click等事件的延迟 <div class="result">点我试试</div> 移动端 时间响应原则: 优先响应移动端 独有事件。 二、解决办法 1、使用touch事件模拟click事件 如下使用touchstart和touched封装了一个移动端的tap事件 可以直接调用idcast中tap方法。 2、使用zepto中已经封装好的tap事件直接调用 $(menuBox).on("tap",callback) zepto下载链接: https://github.com/madrobby/zepto 文章来源: 移动端click延迟和tap事件

What is the difference between Zepto and jQuery 2?

笑着哭i 提交于 2019-12-02 17:22:19
There are those two similar projects: Zepto.js Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. jQuery 2.0 jQuery 2.0 beta: Here is your taste of the future, a jQuery that can be faster and smaller without the need to support IE 6, 7, or 8. It’s a great choice for platform-specific HTML applications. Is this only about performance or do they follow different approaches? MHD The primary difference between Zepto.js and jQuery are their respective file sizes of Zepto.js's ~20kb (minified, not gzipped) instead of jQuery's ~80kb,And Zepto.js's ~10kb

jquery/zepto仿手机app左滑删除效果

☆樱花仙子☆ 提交于 2019-12-02 13:09:43
jquery/zepto仿手机app左滑删除效果 在给你们重新贴一遍,原理自己要弄懂。我写的水平也有限,希望diss我的时候能拿出代码。不要光嘴炮。 html css里列表内容正常布局,删除键(class=”addit”)用绝对定位(position:absolute;top: 0px;right:0px;),记得绝对定位的父级要加上(position:relative;) 绝对定位和相对定位的区别请点击这里~~~ < div style = "position: relative" > < div class = "apply" > < div class = "item" > < a href = "javascript:void(0)" > < div class = "pic" > < img src = "img/message/z_message4.png" /> </ div > < div class = "name" > < span class = "fl" > 订单通知 </ span > < span class = "fr f_clr99" > 2016-05-12 </ span > </ div > </ a > </ div > </ div > < div class = "addit delete" > 删除 </ div > </ div >

Backbone.js + Zepto.js examples

删除回忆录丶 提交于 2019-12-02 05:33:53
问题 I am looking for an example set that utilizes Backbone.js + Zepto.js to build Mobile Web Application. 回答1: You can get simple example in this link. http://trigger.io/cross-platform-application-development-blog/2012/03/02/how-to-build-fast-html5-mobile-apps-using-backbone-js-zepto-js-and-trigger-io/ 来源: https://stackoverflow.com/questions/9737826/backbone-js-zepto-js-examples