Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(hot key and mousemove): hot key fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Jul 31, 2020
1 parent 27ba0a3 commit 1ad40cf
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 31 deletions.
38 changes: 34 additions & 4 deletions src/controllers/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,32 @@ export default function luckysheetHandler() {
}

const os = browser.detectOS(), isMac = os=="Mac"?true:false, scrollNum = isMac?1:3;

if (!Date.now)
Date.now = function() { return new Date().getTime(); };
//requestAnimationFrame method
(function() {
'use strict';

var vendors = ['webkit', 'moz'];
for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
var vp = vendors[i];
window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
|| window[vp+'CancelRequestAnimationFrame']);
}
if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
|| !window.requestAnimationFrame || !window.cancelAnimationFrame) {
var lastTime = 0;
window.requestAnimationFrame = function(callback) {
var now = Date.now();
var nextTime = Math.max(lastTime + 16, now);
return setTimeout(function() { callback(lastTime = nextTime); },
nextTime - now);
};
window.cancelAnimationFrame = clearTimeout;
}
}());

//滚动监听
$("#luckysheet-cell-main").scroll(function () {
Expand Down Expand Up @@ -1077,7 +1103,7 @@ export default function luckysheetHandler() {
$(document).mousemove(function (event) {
luckysheetPostil.overshow(event); //有批注显示

clearInterval(Store.jfautoscrollTimeout);
window.cancelAnimationFrame(Store.jfautoscrollTimeout);

if(formula.functionResizeStatus){
let y = event.pageY;
Expand Down Expand Up @@ -1268,7 +1294,7 @@ export default function luckysheetHandler() {
Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
}

Store.jfautoscrollTimeout = setInterval(function () {
function mouseRender() {
if (Store.luckysheet_scroll_status && !Store.luckysheet_cols_change_size && !Store.luckysheet_rows_change_size) {
let mouse = mouseposition(event.pageX, event.pageY);
let left = $("#luckysheet-scrollbar-x").scrollLeft(),
Expand Down Expand Up @@ -1913,7 +1939,11 @@ export default function luckysheetHandler() {
else if (!!formula.rangeMove) {
formula.rangeMoveDraging(event, formula.rangeMovexy, formula.rangeMoveObj.data("range"), formula.rangeMoveObj, Store.sheetBarHeight, Store.statisticBarHeight);
}
}, 1);

Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
}

Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
}
});

Expand All @@ -1938,7 +1968,7 @@ export default function luckysheetHandler() {
}

Store.luckysheet_select_status = false;
clearTimeout(Store.jfautoscrollTimeout);
window.cancelAnimationFrame(Store.jfautoscrollTimeout);
Store.luckysheet_scroll_status = false;

$("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle").css("cursor","crosshair").end().find(".luckysheet-cs-draghandle").css("cursor","move");
Expand Down
1 change: 1 addition & 0 deletions src/controllers/pivotTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,7 @@ const pivotTable = {

$("#luckysheet-dialog-pivotTable-range").html(getRangetxt(_this.pivotDataSheetIndex, _this.pivot_select_save));
$("#luckysheet-modal-dialog-slider-pivot").show();
sheetmanage.sheetBarShowAndHide();
luckysheetsizeauto();
},
getComposeArray: function (data) {
Expand Down
52 changes: 27 additions & 25 deletions src/controllers/sheetMove.js
Original file line number Diff line number Diff line change
Expand Up @@ -1762,30 +1762,32 @@ function getNextIndex(direction, focusIndex, strIndex, endIndex) {
let stValue = Store.flowdata[strIndex][focusIndex];

if(getObjType(stValue) == "object" && isRealNull(stValue.v)){
stNull = false;
stNull = true;
}
else if(isRealNull(stValue)){
stNull = false;
stNull = true;
}
else{
stNull = true;
stNull = false;
}

console.log(stNull, "stNull");

let cellNull = [], i = 0;
for(let r = strIndex + 1; r <= endIndex; r++){
let cell = Store.flowdata[r][focusIndex];

if(getObjType(cell) == "object" && isRealNull(cell.v)){
cellNull.push(false);
cellNull.push(true);
}
else if(isRealNull(cell)){
cellNull.push(false);
cellNull.push(true);
}
else{
cellNull.push(true);
cellNull.push(false);
}

if(cellNull.length == 1 && stNull && cellNull[i] == false){
if(cellNull.length == 1 && stNull==true && cellNull[i] == false){
index = strIndex + i + 1;
break;
}
Expand Down Expand Up @@ -1817,27 +1819,27 @@ function getNextIndex(direction, focusIndex, strIndex, endIndex) {
let stValue = Store.flowdata[endIndex][focusIndex];

if(getObjType(stValue) == "object" && isRealNull(stValue.v)){
stNull = false;
stNull = true;
}
else if(isRealNull(stValue)){
stNull = false;
stNull = true;
}
else{
stNull = true;
stNull = false;
}

let cellNull = [], i = 0;
for(let r = endIndex - 1; r >= strIndex; r--){
let cell = Store.flowdata[r][focusIndex];

if(getObjType(cell) == "object" && isRealNull(cell.v)){
cellNull.push(false);
cellNull.push(true);
}
else if(isRealNull(cell)){
cellNull.push(false);
cellNull.push(true);
}
else{
cellNull.push(true);
cellNull.push(false);
}

if(cellNull.length == 1 && stNull && cellNull[i] == false){
Expand Down Expand Up @@ -1872,27 +1874,27 @@ function getNextIndex(direction, focusIndex, strIndex, endIndex) {
let stValue = Store.flowdata[focusIndex][strIndex];

if(getObjType(stValue) == "object" && isRealNull(stValue.v)){
stNull = false;
stNull = true;
}
else if(isRealNull(stValue)){
stNull = false;
stNull = true;
}
else{
stNull = true;
stNull = false;
}

let cellNull = [], i = 0;
for(let c = strIndex + 1; c <= endIndex; c++){
let cell = Store.flowdata[focusIndex][c];

if(getObjType(cell) == "object" && isRealNull(cell.v)){
cellNull.push(false);
cellNull.push(true);
}
else if(isRealNull(cell)){
cellNull.push(false);
cellNull.push(true);
}
else{
cellNull.push(true);
cellNull.push(false);
}

if(cellNull.length == 1 && stNull && cellNull[i] == false){
Expand Down Expand Up @@ -1927,27 +1929,27 @@ function getNextIndex(direction, focusIndex, strIndex, endIndex) {
let stValue = Store.flowdata[focusIndex][endIndex];

if(getObjType(stValue) == "object" && isRealNull(stValue.v)){
stNull = false;
stNull = true;
}
else if(isRealNull(stValue)){
stNull = false;
stNull = true;
}
else{
stNull = true;
stNull = false;
}

let cellNull = [], i = 0;
for(let c = endIndex - 1; c >= strIndex; c--){
let cell = Store.flowdata[focusIndex][c];

if(getObjType(cell) == "object" && isRealNull(cell.v)){
cellNull.push(false);
cellNull.push(true);
}
else if(isRealNull(cell)){
cellNull.push(false);
cellNull.push(true);
}
else{
cellNull.push(true);
cellNull.push(false);
}

if(cellNull.length == 1 && stNull && cellNull[i] == false){
Expand Down
12 changes: 10 additions & 2 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,17 @@ const sheetmanage = {
if (formula.rangestart) {
formula.createRangeHightlight();
}


this.sheetBarShowAndHide(index);
},
sheetBarShowAndHide(index){
let $c = $("#luckysheet-sheet-container-c");
$c.scrollLeft($sheet.offset().left);

if(index!=null){
let $sheet = $("#luckysheet-sheets-item" + index);
$c.scrollLeft($sheet.offset().left);
}


let c_width = $c.width(), c_srollwidth = $c[0].scrollWidth, scrollLeft = $c.scrollLeft();

Expand Down

0 comments on commit 1ad40cf

Please sign in to comment.