【问题标题】:using ion-range slider in angular js project throw e.preventDefault() is undefined?在 Angular js 项目中使用离子范围滑块 throw e.preventDefault() 未定义?
【发布时间】:2015-07-29 13:40:36
【问题描述】:

我想在我的 Angular 项目中使用 ion-range slider
我在控制器中创建了名为 ionRangeSlider 的 Angular 指令。
我也在我的项目中使用requireJS
但是当试图拖动范围时我有一个错误:e.preventDefault() is undefined ?

【问题讨论】:

    标签: jquery angularjs angularjs-directive


    【解决方案1】:

    在源文件中 ion.rangeSlider.Js 替换 e =>eventthis.pageX => event.pageX

     pointerDown: function (target, e) {
            event.preventDefault();
            var x = event.pageX || event.originalEvent.touches && event.originalEvent.touches[0].pageX;
            if (event.button === 2) {
                return;
            }
    
            this.current_plugin = this.plugin_count;
            this.target = target;
    
            this.is_active = true;
            this.dragging = true;
    
            this.coords.x_gap = this.$cache.rs.offset().left;
            this.coords.x_pointer = x - this.coords.x_gap;
    
            this.calcPointer();
            this.changeLevel(target);
    
            if (is_old_ie) {
                $("*").prop("unselectable", true);
            }
    
            this.$cache.line.trigger("focus");
    
            this.updateScene();
        },
    
        pointerClick: function (target, e) {
            event.preventDefault();
            var x = event.pageX || event.originalEvent.touches && event.originalEvent.touches[0].pageX;
            if (event.button === 2) {
                return;
    
    
            }
    
            this.current_plugin = this.plugin_count;
            this.target = target;
    
            this.is_click = true;
            this.coords.x_gap = this.$cache.rs.offset().left;
            this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
    
            this.force_redraw = true;
            this.calc();
    
            this.$cache.line.trigger("focus");
        },
    
        key: function (target, e) {
            if (this.current_plugin !== this.plugin_count || event.altKey || event.ctrlKey || event.shiftKey || event.metaKey) {
                return;
            }
    
            switch (event.which) {
                case 83: // W
                case 65: // A
                case 40: // DOWN
                case 37: // LEFT
                    event.preventDefault();
                    this.moveByKey(false);
                    break;
    
                case 87: // S
                case 68: // D
                case 38: // UP
                case 39: // RIGHT
                    event.preventDefault();
                    this.moveByKey(true);
                    break;
            }
    
            return true;
        },
    

    【讨论】:

      猜你喜欢
      • 2016-03-23
      • 1970-01-01
      • 2013-07-28
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 2019-11-08
      • 2019-06-21
      • 1970-01-01
      相关资源
      最近更新 更多