MCPcopy Index your code
hub / github.com/documentationjs/documentation / drag

Function drag

src/default_theme/assets/split.js:293–330  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

291 // ---------------------------------------------------------------------
292 // | <- this.start this.size -> |
293 function drag(e) {
294 var offset;
295 var a = elements[this.a];
296 var b = elements[this.b];
297
298 if (!this.dragging) { return }
299
300 // Get the offset of the event from the first side of the
301 // pair `this.start`. Then offset by the initial position of the
302 // mouse compared to the gutter size.
303 offset =
304 getMousePosition(e) -
305 this.start +
306 (this[aGutterSize] - this.dragOffset);
307
308 if (dragInterval > 1) {
309 offset = Math.round(offset / dragInterval) * dragInterval;
310 }
311
312 // If within snapOffset of min or max, set offset to min or max.
313 // snapOffset buffers a.minSize and b.minSize, so logic is opposite for both.
314 // Include the appropriate gutter sizes to prevent overflows.
315 if (offset <= a.minSize + snapOffset + this[aGutterSize]) {
316 offset = a.minSize + this[aGutterSize];
317 } else if (
318 offset >=
319 this.size - (b.minSize + snapOffset + this[bGutterSize])
320 ) {
321 offset = this.size - (b.minSize + this[bGutterSize]);
322 }
323
324 // Actually adjust the size.
325 adjust.call(this, offset);
326
327 // Call the drag callback continously. Don't do anything too intensive
328 // in this callback.
329 getOption(options, 'onDrag', NOOP)();
330 }
331
332 // Cache some important sizes when drag starts, so we don't have to do that
333 // continously:

Callers

nothing calls this directly

Calls 2

getMousePositionFunction · 0.85
getOptionFunction · 0.85

Tested by

no test coverage detected