9 changed files with 520 additions and 233 deletions
@ -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); |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,113 @@ |
|||
.luckysheet-zoom-content{ |
|||
position: absolute; |
|||
width:210px; |
|||
right: 0px; |
|||
height: 22px; |
|||
line-height: 22px; |
|||
text-align: right; |
|||
padding-right: 10px; |
|||
white-space: nowrap; |
|||
overflow: hidden; |
|||
display: flex; |
|||
align-items: center; |
|||
user-select: none; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-minus{ |
|||
position: absolute; |
|||
left: 0px; |
|||
width: 20px; |
|||
height:20px; |
|||
cursor: pointer; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-minus-icon{ |
|||
background-image:url('data:image/svg+xml;base64,PD94bWwgdmVy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3ZnPg=='); |
|||
width: 14px; |
|||
height: 2px; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-minus:hover{ |
|||
background-color: #E1E4E8; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-slider{ |
|||
position: absolute; |
|||
left: 25px; |
|||
width: 100px; |
|||
height: 100%; |
|||
display: flex; |
|||
align-items: center; |
|||
} |
|||
|
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-slider .luckysheet-zoom-line{ |
|||
position: absolute; |
|||
width: 100px; |
|||
height: 2px; |
|||
background: #E1E4E8; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-slider .luckysheet-zoom-cursor{ |
|||
position: absolute; |
|||
width: 8px; |
|||
height: 8px; |
|||
border-radius: 8px; |
|||
background: #B5BDB8; |
|||
cursor: pointer; |
|||
z-index: 2; |
|||
transition: all 0.3s; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-slider .luckysheet-zoom-cursor:hover{ |
|||
transform: scale(1.2); |
|||
transform-origin: center center; |
|||
background: rgb(160, 160, 160); |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-slider .luckysheet-zoom-hundred{ |
|||
position: absolute; |
|||
width: 2px; |
|||
height: 4px; |
|||
left: 49px; |
|||
background: #1E1E1F; |
|||
} |
|||
|
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-plus{ |
|||
position: absolute; |
|||
left: 130px; |
|||
width: 20px; |
|||
height:20px; |
|||
cursor: pointer; |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: center; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-plus .luckysheet-zoom-plus-icon{ |
|||
background-image:url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTRweCIgaGVpZ2h0PSIxNHB4IiB2aWV3Qm94PSIwIDAg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0iNiIgd2lkdGg9IjE0IiBoZWlnaHQ9IjIiPjwvcmVjdD4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+'); |
|||
width: 14px; |
|||
height: 14px; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-plus:hover{ |
|||
background-color: #E1E4E8; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-ratioText{ |
|||
position: absolute; |
|||
left: 155px; |
|||
width: 60px; |
|||
color: #1E1E1F; |
|||
font-size: 12px; |
|||
text-align: left; |
|||
cursor: pointer; |
|||
} |
|||
|
|||
.luckysheet-zoom-content .luckysheet-zoom-ratioText:hover{ |
|||
background-color: #E1E4E8; |
|||
} |
|||
Loading…
Reference in new issue