Changeset 1340


Ignore:
Timestamp:
02/03/18 11:32:43 (4 months ago)
Author:
gogo
Message:

#1600 - improve scroll on enter new paragraph

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1339 r1340  
    57055705}; 
    57065706 
     5707/** Scroll the viewport so that the given element is viewable 
     5708 *  if it is not already so. 
     5709 */ 
     5710 
     5711Xinha.prototype.scrollElementIntoViewport = function(e) 
     5712{ 
     5713  if(!e) 
     5714  { 
     5715    e = this.getParentElement(); 
     5716    if(!e) 
     5717    { 
     5718      return; 
     5719    } 
     5720  } 
     5721   
     5722  // This was at one time limited to Gecko only, but I see no reason for it to be. - James 
     5723  var position = Xinha.getElementTopLeft(e);   
     5724  var currentScroll = this.scrollPos(this._iframe.contentWindow); 
     5725  var currentSize   = Xinha.viewportSize(this._iframe.contentWindow); 
     5726   
     5727  var canSeeX = [currentScroll.x, currentScroll.x + (currentSize.x*0.9)]; 
     5728  var canSeeY = [currentScroll.y, currentScroll.y + (currentSize.y*0.9)]; 
     5729  if(   canSeeX[0] <= position.left 
     5730    &&  canSeeX[1] >= position.left 
     5731    &&  canSeeY[0] <= position.top 
     5732    &&  canSeeY[1] >= position.top 
     5733  ) 
     5734  { 
     5735    // The item is in the viewport, no scroll 
     5736    return; 
     5737  } 
     5738   
     5739  this._iframe.contentWindow.scrollTo(position.left, Math.min(position.top,position.top-(currentSize.y*0.1))); 
     5740}; 
     5741 
    57075742/** Get the edited HTML 
    57085743 *   
  • trunk/modules/Gecko/paraHandlerBest.js

    r1338 r1340  
    889889      } 
    890890       
    891       this.editor.scrollToElement(holdEnd); 
     891      this.editor.scrollElementIntoViewport(holdEnd); 
     892      //this.editor.scrollToElement(holdEnd); 
    892893    } 
    893894    catch (e) 
Note: See TracChangeset for help on using the changeset viewer.