index.wxs 905 B

12345678910111213141516171819202122232425262728293031323334
  1. function changing(event, ownerInstance) {
  2. setActiveBarPercent(
  3. ownerInstance,
  4. event.detail.value,
  5. event.currentTarget.dataset.max
  6. );
  7. ownerInstance.callMethod("setFilterDistance", event);
  8. return false;
  9. }
  10. function changeValue(newValue, oldValue, ownerInstance, instance) {
  11. setActiveBarPercent(ownerInstance, newValue, instance.getDataset().max);
  12. return false;
  13. }
  14. function setActiveBarPercent(ownerInstance, value, max) {
  15. console.log(ownerInstance);
  16. var active = ownerInstance.selectComponent(".slider_active");
  17. var block = ownerInstance.selectComponent(".slider_block");
  18. var width = (parseInt(value) / parseInt(max)) * 100;
  19. if (width < 1) {
  20. width = 0;
  21. }
  22. active.setStyle({ width: width + "%" });
  23. block.setStyle({
  24. left: width + "%",
  25. transform: "translateX(-" + width + "%)",
  26. });
  27. }
  28. module.exports = {
  29. changing: changing,
  30. changeValue: changeValue,
  31. };