Browse Source

移动端适配

master
wpxp123456 5 years ago
parent
commit
022dfb4585
  1. 53
      src/css/luckysheet-core.css
  2. 261
      src/luckysheet-core.js
  3. 2
      src/luckysheet-function.js

53
src/css/luckysheet-core.css

@ -1404,7 +1404,7 @@ body:not(.ewa-ipad) .jfgrid-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .jfgrid
margin-top: 2px;
display: none;
/*transition: all 0.1s;*/
background-color: rgba(252,195,195, 0.5);
background-color: rgba(194, 194, 194, 0.5);
}
.jfgrid-rows-h-selected {
@ -1893,7 +1893,7 @@ body:not(.ewa-ipad) .jfgrid-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .jfgrid
position: absolute;
pointer-events: none;
z-index: 16;
border: 1px dashed #C83D3D;
border: 1px dashed #0188fb;
margin: -1px 0 0 -1px;
display: none;
/*transition: all 0.1s;*/
@ -1981,6 +1981,55 @@ body:not(.ewa-ipad) .jfgrid-cols-h-cell-nosel:hover, body:not(.ewa-ipad) .jfgrid
width: 2px;
}
.jfgrid-cs-touchhandle{
display: none;
position: absolute;
width: 16px;
height: 16px;
padding: 5px;
z-index: 10;
pointer-events: auto;
touch-action: auto;
}
.jfgrid-cs-touchhandle:before{
content: '';
display: block;
width: 16px;
height: 16px;
border: 0.5px solid rgba(0, 0, 0, 0.15);
background-color: #ffffff;
box-sizing: border-box;
border-radius: 50%;
}
.jfgrid-cs-touchhandle-lt{
left: -13px;
top: -13px;
}
.jfgrid-cs-touchhandle-lb{
left: -13px;
bottom: -13px;
}
.jfgrid-cs-touchhandle-rt{
right: -13px;
top: -13px;
}
.jfgrid-cs-touchhandle-rb{
right: -13px;
bottom: -13px;
}
.jfgrid-cs-touchhandle .jfgrid-cs-touchhandle-btn{
position: absolute;
width: 10px;
height: 10px;
left: 8px;
top: 8px;
background-color: #018ffb;
background-position: center;
box-sizing: border-box;
border-radius: 50%;
z-index: 11;
}
#jfgrid-dynamicArray-hightShow {
position: absolute;
pointer-events: none;

261
src/luckysheet-core.js

@ -372,6 +372,8 @@
'<div class="jfgrid-cs-draghandle-bottom jfgrid-cs-draghandle"></div>' +
'<div class="jfgrid-cs-draghandle-left jfgrid-cs-draghandle"></div>' +
'<div class="jfgrid-cs-draghandle-right jfgrid-cs-draghandle"></div>' +
'<div class="jfgrid-cs-touchhandle jfgrid-cs-touchhandle-lt"><div class="jfgrid-cs-touchhandle-btn"></div></div>' +
'<div class="jfgrid-cs-touchhandle jfgrid-cs-touchhandle-rb"><div class="jfgrid-cs-touchhandle-btn"></div></div>' +
'</div>' +
'</div>' +
'<div id="jfgrid-postil-showBoxs"></div>' +
@ -672,7 +674,7 @@
jfgrid.jfgridConfigsetting = jfgridConfigsetting;
var jfgriddefaultstyle = {
font: 'normal '+ Math.ceil(10*devicePixelRatio) +'pt 微软雅黑, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif',
font: 'normal '+ Math.ceil(10 * window.devicePixelRatio) +'pt 微软雅黑, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif',
fillStyle: "#000000",
textBaseline: "middle",
strokeStyle: "#dfdfdf",
@ -1783,9 +1785,177 @@
};
//设备是移动端
if(jfgrid.browser.mobilecheck()){
var mobilecheck = jfgrid.browser.mobilecheck();
if(mobilecheck){
//去除滚动条
cellMainSrollBarSize = 0;
//滑动滚动表格
var jfgrid_touchmove_status = false,
jfgrid_touchmove_startPos = {},
jfgrid_touchhandle_status = false;
$(document).on("touchstart", "#jfgrid-grid-window-1", function(event){
jfgrid_touchmove_status = true;
var touch = event.originalEvent.targetTouches[0];
jfgrid_touchmove_startPos = {
x: touch.pageX,
y: touch.pageY
}
})
$(document).on("touchmove", "#jfgrid-grid-window-1", function(event){
if(event.originalEvent.targetTouches.length > 1 || (event.scale && event.scale !== 1)){
return;
}
var touch = event.originalEvent.targetTouches[0];
if(jfgrid_touchmove_status){//滚动
var slideX = touch.pageX - jfgrid_touchmove_startPos.x;
var slideY = touch.pageY - jfgrid_touchmove_startPos.y;
jfgrid_touchmove_startPos = {
x: touch.pageX,
y: touch.pageY
}
var scrollLeft = $("#jfgrid-cell-main").scrollLeft();
var scrollTop = $("#jfgrid-cell-main").scrollTop();
scrollLeft -= slideX;
scrollTop -= slideY;
if(scrollLeft < 0){
scrollLeft = 0;
}
if(scrollTop < 0){
scrollTop = 0;
}
if(Math.abs(slideX) < Math.abs(slideY)){
$("#jfgrid-scrollbar-y").scrollTop(scrollTop);
}
else{
$("#jfgrid-scrollbar-x").scrollLeft(scrollLeft);
}
}
else if(jfgrid_touchhandle_status){//选区
var mouse = jfgrid.mouseposition(touch.pageX, touch.pageY);
var x = mouse[0] + $("#jfgrid-cell-main").scrollLeft();
var y = mouse[1] + $("#jfgrid-cell-main").scrollTop();
var rowLocation = jfgrid.rowLocation(y),
row = rowLocation[1],
row_pre = rowLocation[0],
row_index = rowLocation[2];
var colLocation = jfgrid.colLocation(x),
col = colLocation[1],
col_pre = colLocation[0],
col_index = colLocation[2];
var last = $.extend(true, {}, jfgird_select_save[jfgird_select_save.length - 1]);
var top = 0, height = 0, rowseleted = [];
if (last.top > row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
if(last.row[1] > last.row_focus){
last.row[1] = last.row_focus;
}
rowseleted = [row_index, last.row[1]];
}
else if (last.top == row_pre) {
top = row_pre;
height = last.top + last.height - row_pre;
rowseleted = [row_index, last.row[0]];
}
else {
top = last.top;
height = row - last.top - 1;
if(last.row[0] < last.row_focus){
last.row[0] = last.row_focus;
}
rowseleted = [last.row[0], row_index];
}
var left = 0, width = 0, columnseleted = [];
if (last.left > col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
if(last.column[1] > last.column_focus){
last.column[1] = last.column_focus;
}
columnseleted = [col_index, last.column[1]];
}
else if (last.left == col_pre) {
left = col_pre;
width = last.left + last.width - col_pre;
columnseleted = [col_index, last.column[0]];
}
else {
left = last.left;
width = col - last.left - 1;
if(last.column[0] < last.column_focus){
last.column[0] = last.column_focus;
}
columnseleted = [last.column[0], col_index];
}
var changeparam = jfgrid.menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
if(changeparam != null){
columnseleted = changeparam[0];
rowseleted= changeparam[1];
top = changeparam[2];
height = changeparam[3];
left = changeparam[4];
width = changeparam[5];
}
last["row"] = rowseleted;
last["column"] = columnseleted;
last["left_move"] = left;
last["width_move"] = width;
last["top_move"] = top;
last["height_move"] = height;
jfgird_select_save[jfgird_select_save.length - 1] = last;
jfgrid.selectHightlightShow();
jfgrid.freezen.scrollFreezen();
}
event.stopPropagation();
})
$(document).on("touchend", function(event){
jfgrid_touchmove_status = false;
jfgrid_touchmove_startPos = {};
jfgrid_touchhandle_status = false;
})
//滑动选择选区
$(document).on("touchstart", ".jfgrid-cs-touchhandle", function(event){
jfgrid_touchhandle_status = true;
event.stopPropagation();
})
//禁止微信下拉拖出微信背景
document.addEventListener("touchmove", function(event){
event.preventDefault();
}, {
passive: false
})
}
jfgrid.controlHistory = {
@ -25069,10 +25239,57 @@
if(i == 0){
if(jfgird_select_save.length == 1){
$("#jfgrid-cell-selected-boxs #jfgrid-cell-selected").css({ "left": jfgird_select_save[i]["left_move"], "width": jfgird_select_save[i]["width_move"], "top": jfgird_select_save[i]["top_move"], "height": jfgird_select_save[i]["height_move"], "display": "block", "border": "1px solid #0188fb" }).find(".jfgrid-cs-draghandle").css("display", "block").end().find(".jfgrid-cs-fillhandle").css("display", "block");
if(mobilecheck){//移动端
$("#jfgrid-cell-selected-boxs #jfgrid-cell-selected").css({
"left": jfgird_select_save[i]["left_move"],
"width": jfgird_select_save[i]["width_move"],
"top": jfgird_select_save[i]["top_move"],
"height": jfgird_select_save[i]["height_move"],
"display": "block",
"border": "1px solid #0188fb"
})
.find(".jfgrid-cs-draghandle")
.css("display", "block")
.end()
.find(".jfgrid-cs-fillhandle")
.css("display", "none")
.end()
.find(".jfgrid-cs-touchhandle")
.css("display", "block");
}
else{
$("#jfgrid-cell-selected-boxs #jfgrid-cell-selected").css({
"left": jfgird_select_save[i]["left_move"],
"width": jfgird_select_save[i]["width_move"],
"top": jfgird_select_save[i]["top_move"],
"height": jfgird_select_save[i]["height_move"],
"display": "block",
"border": "1px solid #0188fb"
})
.find(".jfgrid-cs-draghandle")
.css("display", "block")
.end()
.find(".jfgrid-cs-fillhandle")
.css("display", "block")
.end()
.find(".jfgrid-cs-touchhandle")
.css("display", "none");
}
}
else{
$("#jfgrid-cell-selected-boxs #jfgrid-cell-selected").css({ "left": jfgird_select_save[i]["left_move"], "width": jfgird_select_save[i]["width_move"], "top": jfgird_select_save[i]["top_move"], "height": jfgird_select_save[i]["height_move"], "display": "block", "border": "1px solid rgba(1, 136, 251, 0.15)" }).find(".jfgrid-cs-draghandle").css("display", "none").end().find(".jfgrid-cs-fillhandle").css("display", "none");
$("#jfgrid-cell-selected-boxs #jfgrid-cell-selected").css({
"left": jfgird_select_save[i]["left_move"],
"width": jfgird_select_save[i]["width_move"],
"top": jfgird_select_save[i]["top_move"],
"height": jfgird_select_save[i]["height_move"],
"display": "block",
"border": "1px solid rgba(1, 136, 251, 0.15)"
})
.find(".jfgrid-cs-draghandle")
.css("display", "none")
.end()
.find(".jfgrid-cs-fillhandle")
.css("display", "none");
}
}
else{
@ -25081,10 +25298,23 @@
if(i == jfgird_select_save.length - 1){
//focus 取选区数组最后一个
$("#jfgrid-cell-selected-focus").css({ "left": jfgird_select_save[i]["left"], "width": jfgird_select_save[i]["width"], "top": jfgird_select_save[i]["top"], "height": jfgird_select_save[i]["height"], "display": "block" });
$("#jfgrid-cell-selected-focus").css({
"left": jfgird_select_save[i]["left"],
"width": jfgird_select_save[i]["width"],
"top": jfgird_select_save[i]["top"],
"height": jfgird_select_save[i]["height"],
"display": "block"
});
//行列数
jfgrid.jfgrid_count_show(jfgird_select_save[i]["left_move"], jfgird_select_save[i]["top_move"], jfgird_select_save[i]["width_move"], jfgird_select_save[i]["height_move"], [r1, r2], [c1, c2]);
//
jfgrid.jfgrid_count_show(
jfgird_select_save[i]["left_move"],
jfgird_select_save[i]["top_move"],
jfgird_select_save[i]["width_move"],
jfgird_select_save[i]["height_move"],
[r1, r2],
[c1, c2]
);
//左上角选择区域框
jfgrid.formula.fucntionboxshow(rf, cf);
}
}
@ -27489,7 +27719,6 @@
});
$("#jfgrid-cell-main, #jfgridTableContent").mousedown(function (event) {
// $("#jfgrid-cell-main, #jfgridTableContent").on('pointerdown', function (event) {
$("#jfgrid-cell-selected").find(".jfgrid-cs-fillhandle").css("cursor","default").end().find(".jfgrid-cs-draghandle").css("cursor","default");
$("#jfgrid-cell-main, #jfgridTableContent, #jfgrid-sheettable_0").css("cursor","default");
@ -28065,8 +28294,10 @@
jfgrid.freezen.scrollAdaptOfselect();
}
jfgridactiveCell();
if(!mobilecheck){ //非移动端聚焦输入框
jfgridactiveCell();
}
if(jfgrid.server.allowUpdate){
//允许编辑后的后台更新时
jfgrid.server.saveParam("mv", jfgrid.currentSheetIndex, jfgird_select_save);
@ -28554,7 +28785,7 @@
}
}
}
return;
}
@ -28638,6 +28869,7 @@
}
}
else {
if (ctrlKey || event.metaKey) {
if (shiftKey) {
if (!jfgrid_shiftkeydown) {
@ -32230,7 +32462,6 @@
jfgrid.jfcountfunc = jfcountfunc;
$(document).mousemove(function (event) {
// $(document).on('pointermove', function (event) {
jfgrid.postil.overshow(event); //有批注显示
clearInterval(jfautoscrollTimeout);
@ -33219,7 +33450,6 @@
});
$(document).mouseup(function (event) {
// $(document).on('pointerup', function (event) {
//数据窗格主体
if (jfgird_select_status) {
@ -49163,7 +49393,7 @@
//清除canvas左上角区域 防止列标题栏序列号溢出显示
jfgridTableContent.clearRect(0, 0, rowHeaderWidth, columeHeaderHeight);
jfgridTableContent.clearRect(0, 0, rowHeaderWidth * devicePixelRatio, columeHeaderHeight * devicePixelRatio);
}
function jfgridDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
@ -49260,7 +49490,7 @@
jfgridTableContent.stroke();
//清除canvas左上角区域 防止列标题栏序列号溢出显示
jfgridTableContent.clearRect(0, 0, rowHeaderWidth, columeHeaderHeight);
jfgridTableContent.clearRect(0, 0, rowHeaderWidth * devicePixelRatio, columeHeaderHeight * devicePixelRatio);
}
function jfgridDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas, ctx, ctxdata) {
@ -54297,6 +54527,7 @@
// },3000);
})();
window.jfgrid = jfgrid;
window.jfgridConfigsetting = jfgridConfigsetting;
return jfgrid;

2
src/luckysheet-function.js

@ -4753,7 +4753,9 @@
setTimeout(function() {
var value = $editer.text(),
valuetxt = value;
console.log(value, kcode)
if (value.length > 0 && value.substr(0, 1) == "=" && kcode != 229) {
// if (value.length > 0 && value.substr(0, 1) == "=") {
value = jfgrid.formula.functionHTMLGenerate(value);
value1 = jfgrid.formula.functionHTMLGenerate(value1txt);

Loading…
Cancel
Save