Results 1 to 3 of 3

Thread: sliderfield drag event

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    52
    Answers
    3

    Default sliderfield drag event

    How can I get the newValue of a sliderfield as it is dragged, rather than only once the user lets go of it?

    This is my code (please excuse the coffeescript):
    PHP Code:
    {
      
    xtype'sliderfield'
      
    name'brightness_slider'
      
    value50
      minValue
    15
      maxValue
    100
      listeners
    :
        
    change: (blahblehblohnewValueoldValue) =>
          @
    adjustBrightness newValue


  2. #2
    Sencha Premium User
    Join Date
    May 2011
    Location
    Gainesville, FL
    Posts
    227
    Answers
    29

    Default

    For stuff like this, you need to look at the source. In the docs, search for "Ext.field.Slider" and hover over the class name. If you click on view source, then "Slider.js", you'll see that Touch is listening to the drag event of this.getComponent(). So in your own source, you add a listener to the slider's initialize event and then attach your own listener:

    Code:
    Ext.define('MyApp.controller.MyController', {
      extend: 'Ext.app.Controller',
    
      config: {
        control: {
          'yoursliderselector': {
            initialize: 'onYourSliderInitialize'
          }
        }
      },
    
      onYourSliderInitialize: function(slider){
        slider.getComponent().on('drag', 'onSliderDrag', this);
      },
    
      onSliderDrag: function(slider){
        console.log('hey look I am dragging the slider');
      }
    });

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    Ext.field.Slider already has a drag event. Here is a fiddle to show using it:



    So no need for listening to the initialize event to listen to the slider field's inner component. It's right on the slider field itself.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •