Farzaneh Sharifi
Farzaneh Sharifi

Reputation: 23

using ion-range slider in angular js project throw e.preventDefault() is undefined?

I want to use ion-range slider in my angular project.
I create angular directive named ionRangeSlider in my controller .
Also I use requireJS too in my project.
but when trying to drag range I had an erorr : e.preventDefault() is undefined ?

Upvotes: 2

Views: 634

Answers (1)

mehrdad
mehrdad

Reputation: 114

In the source file ion.rangeSlider.Js Replace e =>event and this.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;
    },

Upvotes: 1

Related Questions