Skip to content

Commit 3cbc8cd

Browse files
committed
feat:add small screen size support EN-6
1 parent 366fd60 commit 3cbc8cd

File tree

3 files changed

+65
-15
lines changed

3 files changed

+65
-15
lines changed

src/enjoyhint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
var $event_element;
1818
var that = this;
1919
var _options = configs || {};
20-
var BTN_NEXT_TEXT = _options.btnNextText || "Next";
21-
var BTN_SKIP_TEXT = _options.btnSkipText || "Skip";
20+
var BTN_NEXT_TEXT = _options.btnNextText;
21+
var BTN_SKIP_TEXT = _options.btnSkipText;
2222

2323
var SHAPE_BACKGROUND_COLOR = _options.backgroundColor || "rgba(0,0,0,0.6)";
2424

src/jquery.enjoyhint.css

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,11 @@
373373
}
374374

375375
.enjoy_hint_label {
376+
display: inline-block;
377+
max-width: 80%;
376378
position: absolute;
377379
overflow: hidden;
380+
text-align: center;
378381
color: white;
379382
z-index: 107;
380383
font-size: 22px;
@@ -384,6 +387,38 @@
384387
transition: opacity 400ms cubic-bezier(0.42, 0, 0.58, 1);
385388
}
386389

390+
@media (max-width : 640px){
391+
.enjoy_hint_label {
392+
font-size: 16px;
393+
}
394+
395+
.enjoyhint_next_btn {
396+
font-size : 200%;
397+
color : #FFF;
398+
line-height : 1.2em;
399+
min-width: 0px;
400+
width: 35px;
401+
height: 35px;
402+
-webkit-border-radius : 50%;
403+
border-radius : 50%;
404+
}
405+
406+
.enjoyhint_prev_btn {
407+
font-size : 200%;
408+
color : #FFF;
409+
line-height : 1.2em;
410+
min-width: 0px;
411+
width: 35px;
412+
height: 35px;
413+
-webkit-border-radius : 50%;
414+
border-radius : 50%;
415+
}
416+
417+
.enjoyhint_skip_btn {
418+
display: none;
419+
}
420+
}
421+
387422
div.kineticjs-content {
388423
position: absolute !important;
389424
}
@@ -394,7 +429,6 @@ div.kineticjs-content {
394429

395430
.enjoy_hint_label {
396431
display: inline-block;
397-
min-width: 200px;
398432
text-align: center;
399433
max-width: 80%;
400434
}

src/jquery.enjoyhint.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
221221
that.options.onSkipClick();
222222
});
223223

224-
that.$prev_btn = $("<div>", { class: that.cl.previous_btn })
224+
that.$prev_btn = $("<div>", { class: that.cl.previous_btn })
225225
.appendTo(that.enjoyhint)
226226
.html("Previous")
227227
.click(function(e) {
@@ -282,6 +282,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
282282
$(window).on("resize", function() {
283283
clearTimeout(doit);
284284
$('.enjoyhint_next_btn').css('visibility', 'hidden');
285+
$('.enjoyhint_prev_btn').css('visibility', 'hidden');
285286
$('.enjoyhint_skip_btn').css('visibility', 'hidden');
286287
$('.enjoy_hint_label').remove()
287288
$("#enjoyhint_arrpw_line").remove()
@@ -314,6 +315,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
314315

315316
that.renderLabelWithShape(that.stepData);
316317
$('.enjoyhint_next_btn').css('visibility', 'visible');
318+
$('.enjoyhint_prev_btn').css('visibility', 'visible');
317319
$('.enjoyhint_skip_btn').css('visibility', 'visible');
318320
}
319321

@@ -791,7 +793,7 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
791793
var bottom_offset = body_size.h - (data.center_y + half_h);
792794
var left_offset = data.center_x - half_w;
793795
var right_offset = body_size.w - (data.center_x + half_w);
794-
796+
795797
var label_shift = 150;
796798
var label_margin = 40;
797799
var label_shift_with_label_height =
@@ -808,7 +810,6 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
808810
{name: 'center_top', common_area: window.innerWidth * top_offset, width: window.innerWidth, height: top_offset},
809811
{name: 'center_bottom', common_area: window.innerWidth * bottom_offset, width: window.innerWidth, height: bottom_offset},
810812
];
811-
812813
var label_horizontal_space_required = label_width;
813814
var label_vertical_space_required = label_shift_with_label_height + 20;
814815

@@ -916,7 +917,6 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
916917

917918
x_from = label_x + label_width/2;
918919
y_from = (data.center_y > label_y + label_height/2) ? label_y + label_height : label_y;
919-
920920
// if data center out of window y scale
921921
if(data.center_y < 0) {
922922
y_to = 20
@@ -949,27 +949,43 @@ CanvasRenderingContext2D.prototype.roundRect = function(x, y, w, h, r) {
949949
if (summoryButtonWidth + distance > window.innerWidth || distance < 0) {
950950
distance = 10;
951951
ver_button_position = y_from < y_to ? label_y - 80 : label_y + label_height + 40
952-
}
952+
}
953953

954-
that.$next_btn.css({
954+
var initial_distance = distance;
955+
var initial_ver_position = ver_button_position;
956+
957+
if (window.innerWidth <= 640) {
958+
distance = 10;
959+
ver_button_position = 10;
960+
that.$next_btn.html('&#8250;');
961+
that.$prev_btn.html('&#8249;');
962+
}
963+
else {
964+
distance = initial_distance;
965+
ver_button_position = initial_ver_position;
966+
that.$next_btn.html('Next');
967+
that.$prev_btn.html('Previous');
968+
}
969+
970+
that.$prev_btn.css({
955971
left: distance,
956972
top: ver_button_position
957973
});
958974

959-
var prev_skip = distance + that.$next_btn.width() + 10;
960-
var left_skip = distance + that.$next_btn.width() + that.$prev_btn.width() + 20;
975+
var left_next = distance + that.$prev_btn.width() + 10;
976+
var left_skip = distance + that.$prev_btn.width() + that.$next_btn.width() + 20;
961977

962978
if (that.nextBtn === "hide") {
963-
prev_skip = distance;
964979
left_skip = distance + that.$prev_btn.width() + 10;
965980
}
966981

967982
if(that.prevBtn === "hide") {
968-
left_skip = distance + that.$next_btn.width() + 10
983+
left_next = distance;
984+
left_skip = distance + that.$next_btn.width() + 10;
969985
}
970986

971-
that.$prev_btn.css({
972-
left: prev_skip,
987+
that.$next_btn.css({
988+
left: left_next,
973989
top: ver_button_position
974990
})
975991

0 commit comments

Comments
 (0)