(e)
| 503 | // It also adds event listeners for mouse/touch events, |
| 504 | // and prevents selection while dragging so avoid the selecting text. |
| 505 | function startDragging(e) { |
| 506 | // Right-clicking can't start dragging. |
| 507 | if ('button' in e && e.button !== 0) { |
| 508 | return |
| 509 | } |
| 510 | |
| 511 | // Alias frequently used variables to save space. 200 bytes. |
| 512 | var self = this; |
| 513 | var a = elements[self.a].element; |
| 514 | var b = elements[self.b].element; |
| 515 | |
| 516 | // Call the onDragStart callback. |
| 517 | if (!self.dragging) { |
| 518 | getOption(options, 'onDragStart', NOOP)(getSizes()); |
| 519 | } |
| 520 | |
| 521 | // Don't actually drag the element. We emulate that in the drag function. |
| 522 | e.preventDefault(); |
| 523 | |
| 524 | // Set the dragging property of the pair object. |
| 525 | self.dragging = true; |
| 526 | |
| 527 | // Create two event listeners bound to the same pair object and store |
| 528 | // them in the pair object. |
| 529 | self.move = drag.bind(self); |
| 530 | self.stop = stopDragging.bind(self); |
| 531 | |
| 532 | // All the binding. `window` gets the stop events in case we drag out of the elements. |
| 533 | global[addEventListener]('mouseup', self.stop); |
| 534 | global[addEventListener]('touchend', self.stop); |
| 535 | global[addEventListener]('touchcancel', self.stop); |
| 536 | global[addEventListener]('mousemove', self.move); |
| 537 | global[addEventListener]('touchmove', self.move); |
| 538 | |
| 539 | // Disable selection. Disable! |
| 540 | a[addEventListener]('selectstart', NOOP); |
| 541 | a[addEventListener]('dragstart', NOOP); |
| 542 | b[addEventListener]('selectstart', NOOP); |
| 543 | b[addEventListener]('dragstart', NOOP); |
| 544 | |
| 545 | a.style.userSelect = 'none'; |
| 546 | a.style.webkitUserSelect = 'none'; |
| 547 | a.style.MozUserSelect = 'none'; |
| 548 | a.style.pointerEvents = 'none'; |
| 549 | |
| 550 | b.style.userSelect = 'none'; |
| 551 | b.style.webkitUserSelect = 'none'; |
| 552 | b.style.MozUserSelect = 'none'; |
| 553 | b.style.pointerEvents = 'none'; |
| 554 | |
| 555 | // Set the cursor at multiple levels |
| 556 | self.gutter.style.cursor = cursor; |
| 557 | self.parent.style.cursor = cursor; |
| 558 | document.body.style.cursor = cursor; |
| 559 | |
| 560 | // Cache the initial sizes of the pair. |
| 561 | calculateSizes.call(self); |
| 562 |
nothing calls this directly
no test coverage detected