隔离jQuery FF4问题

如何解决隔离jQuery FF4问题

| 为了回应另一个用户,我已经升级了jQuery插件
iCheckbox
,使其可以与jQuery 1.5和1.6(在Safari中)一起使用。这在我的回答中有描述: jQuery 1.4.2适用于iCheckBox而非jQuery 1.6 但是由于某种原因,它在FF4中不起作用,我需要帮助,在下面的代码中找到影响FF4的错误: http://fiddle.jshell.net/mikkelbreum/HAGMp/ 我希望获得帮助以使其正常工作,以及有关如何使用Firebug调试此类内容的一些一般性提示(我不知道它会产生任何错误,这就是问题所在,所以我不知道在哪里会出错。但这可能与动画或条件检查有关。) 打开这是Safari(有效),在FF4中(损坏,没有动画发生): http://fiddle.jshell.net/mikkelbreum/HAGMp/show/ 我也想知道它是否可以在IE7,8,9中工作?     

解决方法

        更新:我对插件进行了更深入的研究,正在进行许多额外的工作,这是一个更苗条的版本,其功能相同,但工作量更少,并且可以在FF4中使用(没有其他CSS / animation插件)下面列出的答案)。 另外,我进行了一些调整-您现在可以在动画结束之前单击图像以将其切换回去,而无需等待动画完成以确定状态-而是使用复选框的状态(即也立即受到影响)。 API是相同的,只是在这里更改了插件的内部。
/*
* iCheckbox - Inspired Checkbox v0.1
*
* Convert a checkbox or multiple checkboxes into iphone style switches.
*
* This is based on the jQuery iphoneSwitch plugin by Daniel LaBare.
*
* Features:
*    * Because checkboxes are used,this is compatable with having javascript off for form submission.
*    * Affects only checkboxes.
*    * Synchronizes the actual state of the checkbox for on or off status.
*    * Completely self-contained for each checkbox.
*    * Changes fire the onchange event of your checkbox.
*    * Relies purely on css for styling... no passing anything but your slider image.
*    * Because functionality is decoupled from CSS,you can assign custom CSS classes if you wish making it possible for multiple version per page.
*    * Completely inline like a normal checkbox. No sliding-door-float madness.
*
* iphoneSwitch Author: Daniel LaBare
*    iCheckbox Author: Bryn Mosher
*   iphoneSwitch Date: 2/4/2008
*      iCheckbox date: 2/26/2010-2/27/2010 (like most of you I\'m a nite owl :P)
*/

// convert the matched element into an iCheckbox if it is a checkbox input
jQuery.fn.iCheckbox = function(start_state,options) {

    if(this.length == 0 || this[0].type != \'checkbox\') return this;

    // define default settings
    var settings = jQuery.extend( {
        // switch_container_src is the outer frame image of the slider
        // you assign the actual slider image via css
        switch_container_src: \'images/iphone_switch_container.gif\',// The height of your slider
        switch_height: 27,// The width of your slider
        switch_width: 94,// switch_speed is the speed of the slider animation.
        // Warning: Your onchange() even won\'t be fired until the end of this!
        switch_speed: 150,// How far your actual slider image has to move to change to the \"off\" state.
        // This can be either positive or negative based on the layout of your image.
        // The \"on\" state expects this image to have backgroundPosition: 0px.
        switch_swing: -53,// CSS class of the container if you wish.
        class_container: \'iCheckbox_container\',// CSS class of the switch.
        // This should have your actual \"on\"/\"off\" image set as its background-image.
        class_switch: \'iCheckbox_switch\',// CSS class of the checkbox if you wish it shown.
        class_checkbox: \'iCheckbox_checkbox\',checkbox_hide: true,// animate off function
        iCheckToggle: function (elem,atime,animOnly) {
            var img = jQuery(elem).siblings(\'img\');
            atime = typeof(atime) == \'number\' ? atime : settings.switch_speed;
            img.stop(true).animate({ backgroundPositionX: (elem.checked ? \'0\' : settings.switch_swing) + \'px\' },{
                duraton: parseInt(atime) > 0 ? atime : 1,easing: \'linear\',step: function(cur,opt){
                   img.css(\"background-position\",opt.now + \"px 0px\");
                }
             });
        },},options);

    // set initial state
    this.prop(\'checked\',start_state == \'on\');

    // create the switch
    return this.each(function() {
        // make the container
        var container = jQuery(this).wrap($(\'<span />\').addClass(settings.class_container)).parent();
        // make the switch image based on starting state
        jQuery(\'<img class=\"\'+settings.class_switch+\'\" src=\"\'+settings.switch_container_src+\'\" />\')
            .appendTo(container);
        // sync the checkbox to initial state
        // must have a positive time for the initial event to fire
        settings.iCheckToggle(this,1);
        // bind clicking on the image
        jQuery(this).siblings(\'.\'+settings.class_switch).click(function (e) {
            jQuery(this).siblings(\'input\').click();
        }).end()
          // assign the class to it
          .addClass(settings.class_checkbox)
          // finally hide the checkbox after everything else is declared - we do this for syntax checking
          .toggle(!settings.checkbox_hide)
          // bind clicking on a visible checkbox
          .change(function (e) {
            settings.iCheckToggle(this,settings.switch_speed,true );
        });
    });
};
您可以在这里进行测试。 原始答案: 在firefox中,背景位置滑动有些古怪,其属性是百分比而不是px(在此处尝试演示,在firefox与chrome中单击单击时显示警报),因此动画引擎只是无法正确处理它。绕过此问题的最简单方法是钩入jQuery中可用的动画/ CSS钩子,您可以在此答案中看到一个有效的示例。 另外,您将想要更改为标准
backgroundProperty
,而不是在这里专门更改为
backgroundPropertyX
,如下所示:
.animate({backgroundPosition: settings.switch_swing+\'px 0\'},\'linear\')
再往下走:
.animate({backgroundPosition: \'0 0\'},\'linear\')
这是在FF4中使用的其他答案的代码,结合了您的演示中的上述内容。 注意:上面的代码更改(仅在此答案中)固定位置,在另一个答案链接中的代码是固定动画以使其到达该位置的功能,例如,此处是没有动画的版本,如果您好奇。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-