Commit 287487da by doszhang

dos

parent 6d78e8b0
...@@ -172,6 +172,7 @@ $(document).ready(function () { ...@@ -172,6 +172,7 @@ $(document).ready(function () {
// $('.logo').css('top',getTranslateDistance(15)); // $('.logo').css('top',getTranslateDistance(15));
$('.flag-list-content').attr('id', 'flag-list-content'); $('.flag-list-content').attr('id', 'flag-list-content');
const colorbarLeft = $('.colorbar').offset().left;
new Sortable(document.getElementById('flag-list-content'), { new Sortable(document.getElementById('flag-list-content'), {
animation: 150, animation: 150,
ghostClass: 'flag-sortable-ghost', ghostClass: 'flag-sortable-ghost',
...@@ -213,7 +214,7 @@ $(document).ready(function () { ...@@ -213,7 +214,7 @@ $(document).ready(function () {
//选择色条触摸开始 //选择色条触摸开始
$('.personal-page .colorbar').on('touchstart', chooseColorStart); $('.personal-page .colorbar').on('touchstart', chooseColorStart);
//选择色条拖动 //选择色条拖动
$('.personal-page .btn-choose-color').on('touchmove', chooseColorMove); $('.personal-page .colorbar').on('touchmove', chooseColorMove);
//红色 //红色
$('.personal-page .btn-red').on('click', { $('.personal-page .btn-red').on('click', {
color: 'red', color: 'red',
...@@ -303,9 +304,7 @@ function changeMainColor(event) { ...@@ -303,9 +304,7 @@ function changeMainColor(event) {
function chooseColorStart(e) { function chooseColorStart(e) {
let touch = e.originalEvent.targetTouches[0]; let touch = e.originalEvent.targetTouches[0];
console.log(touch); startX = (touch.pageX - colorbarLeft) / fontSize;
startX = touch.pageX / fontSize;
} }
function chooseColorMove(e) { function chooseColorMove(e) {
...@@ -315,36 +314,31 @@ function chooseColorMove(e) { ...@@ -315,36 +314,31 @@ function chooseColorMove(e) {
} }
timer = setTimeout(() => { timer = setTimeout(() => {
let touch = e.originalEvent.targetTouches[0]; let touch = e.originalEvent.targetTouches[0];
moveX = touch.pageX / fontSize; moveX = (touch.pageX - colorbarLeft) / fontSize;
let left = parseFloat($('.personal-page .btn-choose-color').css('left')) / fontSize;
left = left + (moveX - startX);
if (left < 4.2916) { if (moveX < 4.2916) {
left = 4.2916; moveX = 4.2916;
} else if (left > 26.62) { } else if (moveX > 26.62) {
left = 26.62; moveX = 26.62;
} }
if (left < 6.59) { if (moveX < 6.59) {
colorIndex = 1; colorIndex = 1;
} else if (left > 6.59 && left < 11) { } else if (moveX > 6.59 && moveX < 11) {
colorIndex = 2; colorIndex = 2;
} else if (left > 11 && left < 15.46) { } else if (moveX > 11 && lefmoveXt < 15.46) {
colorIndex = 3; colorIndex = 3;
} else if (left > 15.46 && left < 19.91) { } else if (moveX > 15.46 && moveX < 19.91) {
colorIndex = 4; colorIndex = 4;
} else if (left > 19.91 && left < 24.38) { } else if (moveX > 19.91 && moveX < 24.38) {
colorIndex = 5; colorIndex = 5;
} else if (left > 24.38) { } else if (moveX > 24.38) {
colorIndex = 6; colorIndex = 6;
} }
$('.personal-page').css('background', colorList[mainColor][colorIndex - 1]); $('.personal-page').css('background', colorList[mainColor][colorIndex - 1]);
$('.personal-page .btn-choose-color').css('left', left + 'rem'); $('.personal-page .btn-choose-color').css('left', moveX + 'rem');
startX = moveX;
}, 5); }, 5);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment