Bug.
I expect the slider to be draggable.
I can not drag the slider bullet, it just moves when I click in the bar.
Create a blank app, add material, add slider component and try to use it.
I have to manually import import 'hammerjs/hammer'; to be able to drag the bullet or add it as a polyfill, but I think that is not cool to have it globally imported.
Slider-toggle (switch) works even when no Hammer.js is imported.
Material ^5.
The slider works fine when importing Hammer.js manually. I think it should be imported here.
I'm pretty sure that's intentional.
In the docs (Slider > Overview):
Note: the sliding behavior for this component requires that HammerJS is loaded on the page.
It's also in the guide for Getting started:
Some components (
mat-slide-toggle,mat-slider,matTooltip) rely on HammerJS for gestures. In order to get the full feature-set of these components, HammerJS must be loaded into the application.
It even says that HammerJS import should be ideally included in src/main.ts:
After installing, import it on your app's entry point (e.g. src/main.ts).
import 'hammerjs';
Closing as this is working as intended. For touch/drag to work hammer.js will need to be loaded.
So why the switch doesn't need that?
@odahcam Doesn't need what? Hammer.js?
Yes, when I used the MatSlideToggleModule it's touch functionalities worked fine without importing Hammer, also it made the Slider drag work, when I removed the toggle, the Slider stopped working again. So I think SliderToggle imports Hammer by itself, while the common Slider doesn't.
It could just be an old version behavior changed in the latest versions, I've update to 5.2.4 and today was the first time I installed and imported Hammer.
My question is, if I'm right of course, why do these components/modules have different behaviors?
i have import hammer.js + MatSlideToggleModule and nothing help :(
Drag is Not working (i am with angular material 5.2.5 and with angular 5.0.0)
Yes, when I used the
MatSlideToggleModuleit's touch functionalities worked fine without importing Hammer, also it made the Slider drag work, when I removed the toggle, the Slider stopped working again. So I think SliderToggle imports Hammer by itself, while the common Slider doesn't.It could just be an old version behavior changed in the latest versions, I've update to 5.2.4 and today was the first time I installed and imported Hammer.
My question is, if I'm right of course, why do these components/modules have different behaviors?
Just putting this here in case someone else runs into this.
I was also having issue with the dragging working. For my app (Angular 7) I had to do these things to get the slider working:
"hammerjs": "^2.0.8")import 'hammerjs'){provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}If I didn't do the last step the dragging of the thumb/disc wouldn't work.
- in app.module.ts:
{provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}
The above made my slider draggable, thanks @matthewdfleming !!!
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Just putting this here in case someone else runs into this.
I was also having issue with the dragging working. For my app (Angular 7) I had to do these things to get the slider working:
"hammerjs": "^2.0.8")import 'hammerjs'){provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}If I didn't do the last step the dragging of the thumb/disc wouldn't work.