This repository has been archived by the owner on Mar 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(zoom gui): zoom plus and minus, restore origin, slider
- Loading branch information
Showing
9 changed files
with
520 additions
and
233 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,151 @@ | ||
import Store from '../store'; | ||
import locale from '../locale/locale'; | ||
import { replaceHtml } from '../utils/util'; | ||
import rhchInit from '../global/rhchInit'; | ||
import luckysheetConfigsetting from './luckysheetConfigsetting'; | ||
import {changeSheetContainerSize} from './resize'; | ||
import { jfrefreshgrid_rhcw } from '../global/refresh'; | ||
|
||
|
||
export function zoomChange(ratio){ | ||
if(Store.flowdata==null || Store.flowdata.length==0){ | ||
return; | ||
} | ||
|
||
Store.zoomRatio = ratio; | ||
|
||
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); | ||
|
||
changeSheetContainerSize(); | ||
} | ||
|
||
|
||
export function zoomInitial(){ | ||
//zoom | ||
Store.rowHeaderWidth = luckysheetConfigsetting.rowHeaderWidth * Store.zoomRatio; | ||
Store.columeHeaderHeight = luckysheetConfigsetting.columeHeaderHeight *Store.zoomRatio; | ||
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5)); | ||
$("#luckysheet-cols-h-c").height((Store.columeHeaderHeight-1.5)); | ||
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columeHeaderHeight-1.5}); | ||
|
||
$("#luckysheet-zoom-minus").click(function(){ | ||
let currentRatio; | ||
if(Store.zoomRatio==null){ | ||
currentRatio = Store.zoomRatio = 1; | ||
} | ||
else{ | ||
currentRatio = Math.ceil(Store.zoomRatio*10)/10; | ||
} | ||
|
||
currentRatio = currentRatio-0.1; | ||
|
||
if(currentRatio<=0.1){ | ||
currentRatio = 0.1; | ||
} | ||
|
||
Store.zoomRatio = currentRatio; | ||
zoomChange(currentRatio); | ||
zoomNumberDomBind(currentRatio); | ||
}); | ||
|
||
$("#luckysheet-zoom-plus").click(function(){ | ||
let currentRatio; | ||
if(Store.zoomRatio==null){ | ||
currentRatio = Store.zoomRatio = 1; | ||
} | ||
else{ | ||
currentRatio = Math.floor(Store.zoomRatio*10)/10; | ||
} | ||
|
||
currentRatio = currentRatio+0.1; | ||
|
||
if(currentRatio>=4){ | ||
currentRatio = 4; | ||
} | ||
|
||
Store.zoomRatio = currentRatio; | ||
zoomChange(currentRatio); | ||
zoomNumberDomBind(currentRatio); | ||
}); | ||
|
||
$("#luckysheet-zoom-slider").click(function(e){ | ||
let xoffset = $(this).offset().left, pageX = e.pageX; | ||
|
||
let currentRatio = positionToRatio(pageX-xoffset); | ||
Store.zoomRatio = currentRatio; | ||
zoomChange(currentRatio); | ||
zoomNumberDomBind(currentRatio); | ||
}); | ||
|
||
$("#luckysheet-zoom-cursor").mousedown(function(e){ | ||
let curentX = e.pageX,cursorLeft = parseFloat($("#luckysheet-zoom-cursor").css("left")); | ||
$(document).off("mousemove.zoomCursor").on("mousemove.zoomCursor",function(event){ | ||
let moveX = event.pageX; | ||
let offsetX = moveX - curentX; | ||
// console.log(moveX, curentX, offsetX); | ||
// curentX = moveX; | ||
// let left = parseFloat($("#luckysheet-zoom-cursor").css("left")); | ||
let pos = cursorLeft + offsetX; | ||
let currentRatio = positionToRatio(pos); | ||
|
||
if(currentRatio>4){ | ||
currentRatio =4; | ||
pos = 100; | ||
} | ||
|
||
if(currentRatio<0.1){ | ||
currentRatio =0.1; | ||
pos = 0; | ||
} | ||
|
||
Store.zoomRatio = currentRatio; | ||
zoomChange(currentRatio); | ||
let r = Math.round(currentRatio*100) + "%"; | ||
$("#luckysheet-zoom-ratioText").html(r); | ||
$("#luckysheet-zoom-cursor").css("left", pos-4); | ||
}); | ||
|
||
$(document).off("mouseup.zoomCursor").on("mouseup.zoomCursor",function(event){ | ||
$(document).off(".zoomCursor"); | ||
}); | ||
|
||
e.stopPropagation(); | ||
}).click(function(e){ | ||
e.stopPropagation(); | ||
}); | ||
|
||
$("#luckysheet-zoom-ratioText").click(function(){ | ||
Store.zoomRatio = 1; | ||
zoomChange(1); | ||
zoomNumberDomBind(1); | ||
}); | ||
|
||
zoomNumberDomBind(Store.zoomRatio); | ||
} | ||
|
||
export function zoomChange(){ | ||
|
||
} | ||
function zoomSlierDown(){ | ||
|
||
} | ||
|
||
function positionToRatio(pos){ | ||
let ratio = 1; | ||
if(pos<50){ | ||
ratio = Math.round((pos*1.8/100 + 0.1)*100)/100; | ||
} | ||
else if(pos>50){ | ||
ratio = Math.round(((pos-50)*6/100 + 1)*100)/100; | ||
} | ||
|
||
return ratio; | ||
} | ||
|
||
function zoomSlierDomBind(ratio){ | ||
let domPos = 50; | ||
if(ratio<1){ | ||
domPos = Math.round((ratio - 0.1)*100 / 0.18)/10; | ||
} | ||
else if(ratio>1){ | ||
domPos = Math.round((ratio - 1)*100 / 0.6)/10+50; | ||
} | ||
$("#luckysheet-zoom-cursor").css("left", domPos-4); | ||
} | ||
|
||
function zoomNumberDomBind(ratio){ | ||
let r = Math.round(ratio*100) + "%"; | ||
$("#luckysheet-zoom-ratioText").html(r); | ||
zoomSlierDomBind(ratio); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.