Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4785

Show
Ignore:
Timestamp:
08/18/06 05:54:57 (2 years ago)
Author:
madrobby
Message:

script.aculo.us: Fix autoscrolling when dragging an element unto a scrollable container, fixes #5017 [thx tomg]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/scriptaculous/CHANGELOG

    r4772 r4785  
    11*SVN* 
     2 
     3* Fix autoscrolling when dragging an element unto a scrollable container, fixes #5017 [thx tomg] 
    24 
    35* Fix a condition where overriding the endeffect on Draggables without overriding the starteffect too leads to a Javascript error [thx Javier Martinez] 
  • spinoffs/scriptaculous/src/dragdrop.js

    r4772 r4785  
    259259    if(!this.handle) this.handle = this.element; 
    260260     
    261     if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) 
     261    if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 
    262262      options.scroll = $(options.scroll); 
     263      this._isScrollChild = Element.childOf(this.element, options.scroll); 
     264    } 
    263265 
    264266    Element.makePositioned(this.element); // fix IE     
     
    427429    pos[0] -= d[0]; pos[1] -= d[1]; 
    428430     
    429     if(this.options.scroll && (this.options.scroll != window)) { 
     431    if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 
    430432      pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; 
    431433      pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; 
     
    491493    Droppables.show(Draggables._lastPointer, this.element); 
    492494    Draggables.notify('onDrag', this); 
    493     Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
    494     Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
    495     Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
    496     if (Draggables._lastScrollPointer[0] < 0) 
    497       Draggables._lastScrollPointer[0] = 0; 
    498     if (Draggables._lastScrollPointer[1] < 0) 
    499       Draggables._lastScrollPointer[1] = 0; 
    500     this.draw(Draggables._lastScrollPointer); 
     495    if (this._isScrollChild) { 
     496      Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
     497      Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
     498      Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
     499      if (Draggables._lastScrollPointer[0] < 0) 
     500        Draggables._lastScrollPointer[0] = 0; 
     501      if (Draggables._lastScrollPointer[1] < 0) 
     502        Draggables._lastScrollPointer[1] = 0; 
     503      this.draw(Draggables._lastScrollPointer); 
     504    } 
    501505     
    502506    if(this.options.change) this.options.change(this); 
  • spinoffs/scriptaculous/test/functional/index.html

    r4117 r4785  
    4242  <li><a href="dragdrop5_test.html" target="test">dragdrop5_test</a></li> 
    4343  <li><a href="dragdrop6_test.html" target="test">dragdrop6_test: snap option</a></li> 
     44  <li><a href="dragdrop7_test.html" target="test">dragdrop7_test</a></li> 
    4445</ul> 
    4546<ul> 
  • spinoffs/scriptaculous/test/unit/element_test.html

    r4628 r4785  
    4848 
    4949<!-- Test Element.childrenWithClassName --> 
    50 <div id="Container"
     50<div id="Container" class="moo hoo"
    5151  <span id="1" class="firstClass">First class</span> 
    5252  <span id="2" class="secondClass">Second class</span> 
     
    7171        elems.each($) 
    7272      },1); 
     73    }}, 
     74     
     75    testElementUp: function() { with(this) { 
     76      assertEqual('Container', $('collect').up().id); 
     77      assertEqual('Container', $('collect').up(1).id); 
     78      assertEqual('Container', $('5').up(2).id); 
     79 
     80      assertEqual('Container', $('collect').up({tagName:'DIV'}).id); 
     81      assertEqual('4', $('5').up({className:'thirdClass'}).id); 
     82       
     83      assertEqual('Container',$('5').up({className:'moo',tagName:'DIV'}).id); 
     84      assertEqual('Container',$('5').up({tag:'div'}).id); 
     85      assertEqual('Container',$('5').up({'class':'moo','tag':'div'}).id); 
     86      assertNull($('5').up({className:'moo',tagName:'IMG'})); 
    7387    }}, 
    7488