Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 2723eb8

Browse files
mitra-derivSandeepsandeep-deriv
authored
add loading bar (#7226)
* add loading bar * Added overlay and loader to prevent user to visit home page and fixed the flickering issue * add line * remove load bar from index file * fix for double loadbar * remove unused import * Added workaround to stop the flickerling * worked on the loader * cleanup comments * Fixed eslint errors Co-authored-by: Sandeep <sandeep@Sandeep-Singhs-MacBook-Pro-C02DJ89BMD6M-Standard.local> Co-authored-by: Sandeep <sandeep@deriv.com> Co-authored-by: Sandeep Rajput <90243468+sandeep-deriv@users.noreply.github.com>
1 parent b6bb976 commit 2723eb8

File tree

8 files changed

+54
-37
lines changed

8 files changed

+54
-37
lines changed

src/javascript/_common/utility.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ const showLoadingImage = (container, theme = 'dark') => {
1313
container.html(loading_div);
1414
};
1515

16+
function removeLoadingImage () {
17+
const loading_wrapper = document.getElementById('redirect-loading');
18+
if (!loading_wrapper) return;
19+
const parent = loading_wrapper.parentNode;
20+
parent.removeChild(loading_wrapper);
21+
}
22+
23+
function showLoading() {
24+
if (!document.getElementById('redirect-loading')) {
25+
const loading_wrapper = document.createElement('div');
26+
loading_wrapper.id = 'redirect-loading';
27+
loading_wrapper.classList.add('redirect-loader');
28+
document.body.appendChild(loading_wrapper);
29+
showLoadingImage(document.getElementById('redirect-loading'));
30+
} else {
31+
showLoadingImage(document.getElementById('redirect-loading'));
32+
}
33+
}
34+
1635
/**
1736
* Returns the highest z-index in the page.
1837
* Accepts a selector to only check those elements,
@@ -438,4 +457,6 @@ module.exports = {
438457
removeObjProperties,
439458
lc_licenseID,
440459
lc_clientID,
460+
showLoading,
461+
removeLoadingImage,
441462
};

src/javascript/app/base/page.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const EuCloseBanner = require('../common/eu_close_baner');
3333
const CloseBanner = require('../common/game_close_banner');
3434
const RedirectBanner = require('../common/redirect_banner');
3535
const DerivBanner = require('../common/deriv_banner');
36+
const { removeLoadingImage } = require('../../_common/utility');
3637
require('../../_common/lib/polyfills/array.includes');
3738
require('../../_common/lib/polyfills/string.includes');
3839

@@ -127,6 +128,9 @@ const Page = (() => {
127128
}
128129
if (Client.isLoggedIn()) {
129130
BinarySocket.wait('authorize', 'website_status', 'get_account_status').then(() => {
131+
setTimeout(() => {
132+
removeLoadingImage();
133+
}, 1000);
130134
RealityCheck.onLoad();
131135
Menu.init();
132136
const is_uk_residence = (Client.get('residence') === 'gb' || State.getResponse('website_status.clients_country') === 'gb');

src/javascript/app/common/redirect_banner.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ const DerivBanner = require('./deriv_banner');
33
const BinarySocket = require('../base/socket');
44
const State = require('../../_common/storage').State;
55
const Client = require('../base/client');
6+
const { showLoading, removeLoadingImage } = require('../../_common/utility');
67
const isEuCountrySelected = require('../../_common/utility').isEuCountrySelected;
78

89
const RedirectBanner = (() => {
9-
1010
const onLoad = () => {
11+
showLoading();
1112
BinarySocket.wait('authorize', 'website_status', 'landing_company').then(() => {
12-
1313
const eu_country = isEuCountrySelected(Client.get('residence')) || isEuCountrySelected(State.getResponse('website_status.clients_country'));
14+
1415
if (eu_country) {
1516
handleRedirect();
1617
} else if (!Cookies.get('row-lp-visited')) {
1718
handleRowRedirect();
1819
}
20+
setTimeout(() => {
21+
removeLoadingImage();
22+
}, 1000);
1923
});
2024

2125
};
@@ -28,6 +32,7 @@ const RedirectBanner = (() => {
2832
};
2933

3034
const loginOnLoad = () => {
35+
showLoading();
3136
BinarySocket.wait('authorize', 'website_status', 'landing_company').then(() => {
3237
const eu_country = isEuCountrySelected(Client.get('residence')) || isEuCountrySelected(State.getResponse('website_status.clients_country'));
3338
const landing_company_shortcode = Client.get('landing_company_shortcode');
@@ -45,8 +50,12 @@ const RedirectBanner = (() => {
4550
handleRedirect();
4651
} else if (eu_country && virtual_account) {
4752
handleRedirect();
53+
} else if (!Cookies.get('row-lp-visited')) {
54+
handleRowRedirect();
4855
}
49-
56+
setTimeout(() => {
57+
removeLoadingImage();
58+
}, 1000);
5059
});
5160

5261
};

src/javascript/app/pages/user/view_popup/view_popup.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const ViewPopup = (() => {
2727
sell_text_updated,
2828
btn_view,
2929
multiplier,
30-
$container,
31-
$loading;
30+
$container;
3231

3332
const popupbox_id = 'inpage_popup_content_box';
3433
const wrapper_id = 'sell_content_wrapper';
@@ -57,8 +56,6 @@ const ViewPopup = (() => {
5756
}
5857

5958
getContract();
60-
61-
setLoadingState(true);
6259
};
6360

6461
const responseContract = (response) => {
@@ -136,8 +133,6 @@ const ViewPopup = (() => {
136133
})();
137134

138135
const showContract = () => {
139-
setLoadingState(false);
140-
141136
if (!$container) {
142137
$container = makeTemplate();
143138
}
@@ -709,24 +704,7 @@ const ViewPopup = (() => {
709704
}
710705
};
711706

712-
const setLoadingState = (show_loading) => {
713-
if (show_loading) {
714-
$loading = $('#trading_init_progress');
715-
if ($loading.length) {
716-
$loading.show();
717-
}
718-
} else {
719-
if ($loading.length) {
720-
$loading.hide();
721-
}
722-
if (btn_view) {
723-
ViewPopupUI.enableButton($(btn_view));
724-
}
725-
}
726-
};
727-
728707
const showMessagePopup = (localized_text, localized_title, msg_class) => {
729-
setLoadingState(false);
730708
const $con = $('<div/>');
731709
$con.prepend($('<div/>', { id: 'sell_bet_desc', class: 'popup_bet_desc drag-handle', text: localized_title }));
732710
$con.append(

src/sass/_common/common.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,4 +1234,18 @@ label + input {
12341234

12351235
.font-style-normal {
12361236
font-style: normal;
1237-
}
1237+
}
1238+
1239+
.redirect-loader {
1240+
position: fixed;
1241+
height: 100vh;
1242+
width: 100%;
1243+
background: $COLOR_WHITE;
1244+
z-index: 1000;
1245+
top: 0;
1246+
left: 0;
1247+
display: flex;
1248+
align-items: center;
1249+
justify-content: center;
1250+
transition: none !important;
1251+
}

src/templates/_common/_layout/layout.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const Layout = () => {
5050
<html>
5151
<Head />
5252
<body className={it.language}>
53+
<div id='redirect-loading' className='redirect-loader' />
5354
<div id='msg_notification' className='notice-msg center-text' />
5455
<div id='page-wrapper'>
5556
<Header />

src/templates/app/logged_in.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ const LoggedIn = () => (
2121
<meta name='referrer' content='origin' />
2222
</head>
2323
<body>
24-
<div id='header-binary'>
25-
<a href={it.url_for('/')}>
26-
<img id='symbol-logo' src={it.url_for('images/logo/symbol.svg')} alt='' />
27-
<img id='type-logo' src={it.url_for('images/logo/type.svg')} alt='Binary.com' />
28-
</a>
29-
</div>
3024
<div id='content-holder'>
3125
<div id='content'>
3226
<div id='login_loading'>

src/templates/app/trade/trading.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import Analysis from './analysis.jsx';
33
import Portfolio from '../user/portfolio.jsx';
4-
import Loading from '../../_common/components/loading.jsx';
54
import DerivBanner from '../../_common/components/deriv_banner.jsx';
65

76
const Trading = () => (
@@ -304,9 +303,6 @@ const Trading = () => (
304303
<div id='all_prices' />
305304
<Analysis />
306305
</div>
307-
<div id='trading_init_progress'>
308-
<Loading />
309-
</div>
310306
</React.Fragment>
311307
);
312308

0 commit comments

Comments
 (0)