f METHOD_NAME(self, ev):
  dx = ev.x - self.mouse_pos[0]
  new_pos = self.thumb_pos + dx
  new_pos = max(self.min_pos, new_pos)
  new_pos = min(new_pos, self.max_pos)
  self.thumb.left = new_pos
  ratio = (new_pos - self.min_pos) / (self.max_pos - self.min_pos)
  value = self.min_value + ratio * self.value_range
  self.value = value
  if self.step is not None:
    # round to step
    nb_steps = round((value - self.min_value) / self.step)
    self.value = self.min_value + self.step * nb_steps
  ev = window.MouseEvent.new('input')
  self.dispatchEvent(ev)