Venturocket / angular-slider

Slider directive for AngularJS.
MIT License
262 stars 121 forks source link

Vertical support #50

Open duryjames opened 10 years ago

duryjames commented 10 years ago

I cant seem to find any support for a vertical slider, has this been implemented? I tried just simply adding css transform to rotate it, but it still listens on moving the mouse left to right.

There is a listener on the mousemove but it is baked in to listen to x.

We could quite easily add a switch here for vertical support, but i don't know what else this would effect

a quick hack of the onMove function line 267 does the desired effect. (changing X to Y)


 onMove = function (event) {
     var eventX, newOffset, newPercent, newValue;

     eventY = event.clientY || event.touches[0].clientY;
     newOffset = eventY + offsetLeft(element) - halfWidth(pointer);
     newOffset = Math.max(Math.min(newOffset, maxOffset), minOffset);
     newPercent = percentOffset(newOffset);
     newValue = minValue + (valueRange * newPercent / 100.0);
     if (range) {
         if (ref === refLow) {
             if (newValue > scope[refHigh]) {
                 ref = refHigh;
                 minPtr.removeClass('active');
                 maxPtr.addClass('active');
             }
         } else {
             if (newValue < scope[refLow]) {
                 ref = refLow;
                 maxPtr.removeClass('active');
                 minPtr.addClass('active');
             }
         }
     }
     newValue = roundStep(newValue, parseInt(scope.precision), parseFloat(scope.step));
     scope[ref] = newValue;
     return scope.$apply();
 };
drgould commented 10 years ago

I'm currently completely rewriting the slider. I'll add this in.

builtbyjay commented 9 years ago

+1 for this feature.