Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

scrolling page accidentally changes sliders values

  • fgenerau
  • fgenerau's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 1 week ago - 1 month 1 week ago #267234 by fgenerau
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 6.6.1+240806
Own server or LimeSurvey hosting: University server
Survey theme/template: fruity
==================
Hi,
I am using a multiple numeric entries type question, with horizontal sliders. The sliders are grouped close to each other in order to allow easy visual comparison between the sliders values. When answering the question on a phone, I need to scroll up and down the page. My issue is that it is way to easy to accidentally change the value of the sliders while trying to scroll. It seems like it is quite a common problem with sliders, but I hope that maybe someone could have an idea here to tackle this problem ?

So far, I have disabled the possibility to change the value of the slider by clicking directly on the track, so that one has to grab the handle to change the value. This helps but doesn't solve the issue completely. I am also thinking about highlighting the slider in some way when the respondant touch it, so that he may at least realize that he may be changing the slider value. My coding abilities are limited and I couldn't get this to work so far. I should add that I do not have access to theme editing.

Guidance about highlighting the slider when the handle is grabbed, or any other way to solve my issue would be greatly appreciated !

EDIT : an nice way to highlight the slider being dragged would be to turn handle red for instance. I guess this can be done using slideStart and slideStop events.
EDIT : I could eventually change the color of the handle using slideStart and slide Stop event and some answers by DenisChenu and tpartner from another thread : [url] forums.limesurvey.org/forum/can-i-do-thi...alue-changes?start=0 [/url]. Here is the javascript to turn the handle red :
Code:
$(document).on('ready pjax:scriptcomplete',function() {
 
    var thisQuestion = $('#question{QID}');
 
    // SlideStart function
    $('.form-control', thisQuestion).on('slideStart', function( event ) {
    $(this).closest('.slider-container').find('.slider-handle').css('background-color', 'red');
    console.log($(this).val());
    console.log($(this));
    console.log($(this).closest(".slider-container").find('.slider-handle')[1]);
    });
  });

Any other idea about how to make sure people don't change sliders values by accident  while scrolling the page is welcome !
Last edit: 1 month 1 week ago by fgenerau. Reason: I made some progress.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
1 month 1 week ago #267271 by DenisChenu

Any other idea about how to make sure people don't change sliders values by accident  while scrolling the page is welcome !
 
I really don't have any idea her !

> I have disabled the possibility to change the value of the slider by clicking directly on the track,

Excellent 1st step !

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • fgenerau
  • fgenerau's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 month 1 week ago - 1 month 1 week ago #267291 by fgenerau
I added some modifications of the slider track appearance that starts when the slideStart event happens, and ends 2 seconds after the slideStop event happens. I am quite satisfied with the results since I think this way it is pretty impossible not to notice that the handle of a slider has been grabbed accidentally.
Here is the javascript code that I used to change the slider track appearance back to normal, 2 seconds ater the slideStop event (it might not be clean at all, since I got there by trial and error...) :
Code:
<script>
$(document).on('ready pjax:scriptcomplete',function() {
 
    var thisQuestion = $('#question{QID}');
 
  $('.form-control', thisQuestion).on('slideStop', function() {
    var thisSlider = $(this);
    setTimeout(function() {
          thisSlider.closest('.slider-container').find('.slider.slider-horizontal .slider-handle').css('background-color', '#121e15f7');
          thisSlider.closest('.slider-container').find('.slider-track').css('background-image', 'linear-gradient(to bottom, #F5F5F5, #F9F9F9)');
          thisSlider.closest('.slider-container').find('.slider-selection').css('background-image', 'linear-gradient(180deg,#84b39a 0,#39993f)');
          thisSlider.closest('.ls-slider-item-row').find('.control-label').css('color','#444444');
          thisSlider.closest('.ls-slider-item-row').find('label').find('span').css('font-size','20px');
      console.log( thisSlider.val());
    }, 1000); // Waits 1000ms (1 second)
    });
  });
</script>
 
EDIT : And I forgot to thank DenisChenu for cheering up, that was much appreciated :)
Last edit: 1 month 1 week ago by fgenerau.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose