TextPage.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. <template>
  2. <div ref="main" class="main">
  3. <div class="layout back" @wheel.prevent.stop="onMouseWheel">
  4. <div class="absolute" v-html="background"></div>
  5. <div class="absolute" v-html="pageDivider"></div>
  6. </div>
  7. <div ref="scrollBox1" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  8. <div ref="scrollingPage1" class="layout over-hidden" @transitionend="onPage1TransitionEnd" @animationend="onPage1AnimationEnd">
  9. <div @copy.prevent="copyText" v-html="page1"></div>
  10. </div>
  11. </div>
  12. <div ref="scrollBox2" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  13. <div ref="scrollingPage2" class="layout over-hidden" @transitionend="onPage2TransitionEnd" @animationend="onPage2AnimationEnd">
  14. <div @copy.prevent="copyText" v-html="page2"></div>
  15. </div>
  16. </div>
  17. <div v-show="showStatusBar" ref="statusBar" class="layout">
  18. <div v-html="statusBar"></div>
  19. </div>
  20. <div
  21. v-show="clickControl" ref="layoutEvents" class="layout events"
  22. oncontextmenu="return false;"
  23. @mousedown.prevent.stop="onMouseDown" @mouseup.prevent.stop="onMouseUp"
  24. @wheel.prevent.stop="onMouseWheel"
  25. @touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchmove.stop="onTouchMove" @touchcancel.prevent.stop="onTouchCancel"
  26. >
  27. <div
  28. v-show="showStatusBar && statusBarClickOpen" @mousedown.prevent.stop @touchstart.stop
  29. @click.prevent.stop="onStatusBarClick"
  30. v-html="statusBarClickable"
  31. ></div>
  32. </div>
  33. <div
  34. v-show="!clickControl && showStatusBar && statusBarClickOpen" class="layout"
  35. @mousedown.prevent.stop @touchstart.stop
  36. @click.prevent.stop="onStatusBarClick"
  37. v-html="statusBarClickable"
  38. >
  39. </div>
  40. <!-- невидимым делать нельзя (display: none), вовремя не подгружаютя шрифты -->
  41. <canvas ref="offscreenCanvas" class="layout" style="visibility: hidden"></canvas>
  42. <div ref="measureWidth" style="position: absolute; visibility: hidden"></div>
  43. </div>
  44. </template>
  45. <script>
  46. //-----------------------------------------------------------------------------
  47. import vueComponent from '../../vueComponent.js';
  48. import {loadCSS} from 'fg-loadcss';
  49. import _ from 'lodash';
  50. import he from 'he';
  51. import './TextPage.css';
  52. import * as utils from '../../../share/utils';
  53. import bookManager from '../share/bookManager';
  54. import DrawHelper from './DrawHelper';
  55. import rstore from '../../../store/modules/reader';
  56. import {clickMap} from '../share/clickMap';
  57. const minLayoutWidth = 100;
  58. const componentOptions = {
  59. watch: {
  60. bookPos: function() {
  61. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  62. this.draw();
  63. if (this.userBookPosChange) {
  64. this.$emit('hide-tool-bar', {show: (this.bookPos == 0 || this.bookPos < this.prevBookPos)});
  65. this.prevBookPos = this.bookPos;
  66. this.userBookPosChange = false;
  67. }
  68. },
  69. bookPosSeen: function() {
  70. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  71. },
  72. settings: function() {
  73. this.debouncedLoadSettings();
  74. },
  75. toggleLayout: function() {
  76. this.updateLayout();
  77. },
  78. inAnimation: function() {
  79. this.updateLayout();
  80. },
  81. },
  82. };
  83. class TextPage {
  84. _options = componentOptions;
  85. toggleLayout = false;
  86. showStatusBar = false;
  87. clickControl = true;
  88. background = null;
  89. pageDivider = null;
  90. page1 = null;
  91. page2 = null;
  92. statusBar = null;
  93. statusBarClickable = null;
  94. lastBook = null;
  95. bookPos = 0;
  96. bookPosSeen = null;
  97. prevBookPos = 0;
  98. userBookPosChange = false;
  99. fontStyle = null;
  100. fontSize = null;
  101. fontName = null;
  102. fontWeight = null;
  103. inAnimation = false;
  104. meta = null;
  105. created() {
  106. this.drawHelper = new DrawHelper();
  107. this.commit = this.$store.commit;
  108. this.dispatch = this.$store.dispatch;
  109. this.config = this.$store.state.config;
  110. this.reader = this.$store.state.reader;
  111. this.debouncedStartClickRepeat = _.debounce((x, y) => {
  112. this.startClickRepeat(x, y);
  113. }, 800);
  114. this.debouncedPrepareNextPage = _.debounce(() => {
  115. this.prepareNextPage();
  116. }, 100);
  117. this.debouncedDrawStatusBar = _.throttle(() => {
  118. this.drawStatusBar();
  119. }, 60);
  120. this.debouncedDrawPageDividerAndOrnament = _.throttle(() => {
  121. this.drawPageDividerAndOrnament();
  122. }, 65);
  123. this.debouncedLoadSettings = _.debounce(() => {
  124. this.loadSettings();
  125. }, 50);
  126. this.debouncedUpdatePage = _.debounce(async(lines) => {
  127. if (!this.pageChangeAnimation)
  128. this.toggleLayout = !this.toggleLayout;
  129. else {
  130. this.page2 = this.page1;
  131. this.toggleLayout = true;
  132. }
  133. if (this.toggleLayout)
  134. this.page1 = this.drawHelper.drawPage(lines);
  135. else
  136. this.page2 = this.drawHelper.drawPage(lines);
  137. await this.doPageAnimation();
  138. }, 10);
  139. this.$root.addEventHook('resize', async() => {
  140. this.$nextTick(this.onResize);
  141. await utils.sleep(500);
  142. this.$nextTick(this.onResize);
  143. });
  144. }
  145. mounted() {
  146. this.context = this.$refs.offscreenCanvas.getContext('2d');
  147. }
  148. hex2rgba(hex, alpha = 1) {
  149. const [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16));
  150. return `rgba(${r},${g},${b},${alpha})`;
  151. }
  152. calcDrawProps() {
  153. const wideLetter = 'Щ';
  154. //preloaded fonts
  155. this.fontList = [`12px '${this.fontName}'`];
  156. //widths
  157. this.realWidth = this.$refs.main.clientWidth;
  158. this.realHeight = this.$refs.main.clientHeight;
  159. this.$refs.layoutEvents.style.width = this.realWidth + 'px';
  160. this.$refs.layoutEvents.style.height = this.realHeight + 'px';
  161. const dual = (this.dualPageMode ? 2 : 1);
  162. this.boxW = this.realWidth - 2*this.indentLR;
  163. this.w = this.boxW/dual - (this.dualPageMode ? 2*this.dualIndentLR : 0);
  164. this.scrollHeight = this.realHeight - (this.showStatusBar ? this.statusBarHeight : 0);
  165. this.h = this.scrollHeight - 2*this.indentTB;
  166. this.lineHeight = this.fontSize + this.lineInterval;
  167. this.pageRowsCount = 1 + Math.floor((this.h - this.lineHeight + this.lineInterval/2)/this.lineHeight);
  168. this.pageLineCount = (this.dualPageMode ? this.pageRowsCount*2 : this.pageRowsCount)
  169. //stuff
  170. this.currentAnimation = '';
  171. this.pageChangeDirectionDown = true;
  172. this.fontShift = this.fontVertShift/100;
  173. this.textShift = this.textVertShift/100 + this.fontShift;
  174. //statusBar
  175. this.$refs.statusBar.style.left = '0px';
  176. this.$refs.statusBar.style.top = (this.statusBarTop ? 1 : this.realHeight - this.statusBarHeight) + 'px';
  177. const sbColor = (this.statusBarColorAsText ? this.textColor : this.statusBarColor);
  178. this.statusBarRgbaColor = this.hex2rgba(sbColor || '#000000', this.statusBarColorAlpha);
  179. const ddColor = (this.dualDivColorAsText ? this.textColor : this.dualDivColor);
  180. this.dualDivRgbaColor = this.hex2rgba(ddColor || '#000000', this.dualDivColorAlpha);
  181. //drawHelper
  182. this.drawHelper.realWidth = this.realWidth;
  183. this.drawHelper.realHeight = this.realHeight;
  184. this.drawHelper.lastBook = this.lastBook;
  185. this.drawHelper.book = this.book;
  186. this.drawHelper.parsed = this.parsed;
  187. this.drawHelper.pageRowsCount = this.pageRowsCount;
  188. this.drawHelper.pageLineCount = this.pageLineCount;
  189. this.drawHelper.dualPageMode = this.dualPageMode;
  190. this.drawHelper.dualIndentLR = this.dualIndentLR;
  191. /*this.drawHelper.dualDivWidth = this.dualDivWidth;
  192. this.drawHelper.dualDivHeight = this.dualDivHeight;
  193. this.drawHelper.dualDivRgbaColor = this.dualDivRgbaColor;
  194. this.drawHelper.dualDivStrokeFill = this.dualDivStrokeFill;
  195. this.drawHelper.dualDivStrokeGap = this.dualDivStrokeGap;
  196. this.drawHelper.dualDivShadowWidth = this.dualDivShadowWidth;*/
  197. this.drawHelper.backgroundColor = this.backgroundColor;
  198. this.drawHelper.statusBarRgbaColor = this.statusBarRgbaColor;
  199. this.drawHelper.fontStyle = this.fontStyle;
  200. this.drawHelper.fontWeight = this.fontWeight;
  201. this.drawHelper.fontSize = this.fontSize;
  202. this.drawHelper.fontName = this.fontName;
  203. this.drawHelper.fontShift = this.fontShift;
  204. this.drawHelper.textColor = this.textColor;
  205. this.drawHelper.textShift = this.textShift;
  206. this.drawHelper.p = this.p;
  207. this.drawHelper.boxW = this.boxW;
  208. this.drawHelper.w = this.w;
  209. this.drawHelper.h = this.h;
  210. this.drawHelper.indentLR = this.indentLR;
  211. this.drawHelper.textAlignJustify = this.textAlignJustify;
  212. this.drawHelper.lineHeight = this.lineHeight;
  213. this.drawHelper.context = this.context;
  214. //альтернатива context.measureText
  215. if (!this.context.measureText(wideLetter).width) {
  216. const ctx = this.$refs.measureWidth;
  217. this.drawHelper.measureText = function(text, style) {
  218. ctx.innerText = text;
  219. ctx.style.font = this.fontByStyle(style);
  220. return ctx.clientWidth;
  221. };
  222. this.drawHelper.measureTextFont = function(text, font) {
  223. ctx.innerText = text;
  224. ctx.style.font = font;
  225. return ctx.clientWidth;
  226. }
  227. }
  228. //statusBar
  229. this.statusBarClickable = this.drawHelper.statusBarClickable(this.statusBarTop, this.statusBarHeight);
  230. //parsed
  231. if (this.parsed) {
  232. let wideLine = wideLetter;
  233. if (!this.drawHelper.measureText(wideLine, {}))
  234. throw new Error('Ошибка measureText');
  235. while (this.drawHelper.measureText(wideLine, {}) < this.w) wideLine += wideLetter;
  236. this.parsed.setSettings({
  237. p: this.p,
  238. w: this.w,
  239. font: this.font,
  240. fontSize: this.fontSize,
  241. wordWrap: this.wordWrap,
  242. cutEmptyParagraphs: this.cutEmptyParagraphs,
  243. addEmptyParagraphs: this.addEmptyParagraphs,
  244. maxWordLength: wideLine.length - 1,
  245. lineHeight: this.lineHeight,
  246. showImages: this.showImages,
  247. showInlineImagesInCenter: this.showInlineImagesInCenter,
  248. imageHeightLines: this.imageHeightLines,
  249. imageFitWidth: this.imageFitWidth,
  250. compactTextPerc: this.compactTextPerc,
  251. testWidth: 0,
  252. measureText: this.drawHelper.measureText.bind(this.drawHelper),
  253. });
  254. }
  255. //scrolling page
  256. const pageSpace = this.scrollHeight - this.pageRowsCount*this.lineHeight;
  257. let top = pageSpace/2;
  258. if (this.showStatusBar)
  259. top += this.statusBarHeight*(this.statusBarTop ? 1 : 0);
  260. let page1 = this.$refs.scrollBox1.style;
  261. let page2 = this.$refs.scrollBox2.style;
  262. page1.perspective = page2.perspective = '3072px';
  263. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  264. page1.height = page2.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px';
  265. page1.top = page2.top = top + 'px';
  266. page1.left = page2.left = this.indentLR + 'px';
  267. page1 = this.$refs.scrollingPage1.style;
  268. page2 = this.$refs.scrollingPage2.style;
  269. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  270. page1.height = page2.height = this.scrollHeight + this.lineHeight + 'px';
  271. }
  272. async checkLoadedFonts() {
  273. let loaded = await Promise.all(this.fontList.map(font => document.fonts.check(font)));
  274. if (loaded.some(r => !r)) {
  275. await Promise.all(this.fontList.map(font => document.fonts.load(font)));
  276. }
  277. }
  278. async loadFonts() {
  279. this.fontsLoading = true;
  280. let close = null;
  281. (async() => {
  282. await utils.sleep(500);
  283. if (this.fontsLoading)
  284. close = this.$root.notify.info('Загрузка шрифта &nbsp;<i class="la la-snowflake icon-rotate" style="font-size: 150%"></i>');
  285. })();
  286. if (!this.fontsLoaded)
  287. this.fontsLoaded = {};
  288. //загрузка дин.шрифта
  289. const loaded = this.fontsLoaded[this.fontCssUrl];
  290. if (this.fontCssUrl && !loaded) {
  291. loadCSS(this.fontCssUrl);
  292. this.fontsLoaded[this.fontCssUrl] = 1;
  293. }
  294. try {
  295. await this.checkLoadedFonts();
  296. } catch (e) {
  297. this.$root.notify.error('Некоторые шрифты не удалось загрузить', 'Ошибка загрузки');
  298. }
  299. this.fontsLoading = false;
  300. if (close)
  301. close();
  302. }
  303. getSettings() {
  304. const settings = this.settings;
  305. for (let prop in rstore.settingDefaults) {
  306. this[prop] = settings[prop];
  307. }
  308. const wf = this.webFontName;
  309. const i = _.findIndex(rstore.webFonts, ['name', wf]);
  310. if (wf && i >= 0) {
  311. this.fontName = wf;
  312. this.fontCssUrl = rstore.webFonts[i].css;
  313. this.fontVertShift = settings.fontShifts[wf] || 0;
  314. }
  315. }
  316. async calcPropsAndLoadFonts(omitLoadFonts) {
  317. this.calcDrawProps();
  318. this.setBackground();
  319. if (!omitLoadFonts)
  320. await this.loadFonts();
  321. if (omitLoadFonts) {
  322. this.draw();
  323. } else {
  324. // ширина шрифта некоторое время выдается неверно,
  325. // не удалось событийно отловить этот момент, поэтому костыль
  326. while (this.checkingFont) {
  327. this.stopCheckingFont = true;
  328. await utils.sleep(100);
  329. }
  330. this.checkingFont = true;
  331. this.stopCheckingFont = false;
  332. try {
  333. const parsed = this.parsed;
  334. let i = 0;
  335. const t = 'Это тестовый текст. Его ширина выдается системой неправильно некоторое время.';
  336. let twprev = 0;
  337. //5 секунд проверяем изменения шрифта
  338. while (!this.stopCheckingFont && i++ < 50 && this.parsed === parsed) {
  339. const tw = this.drawHelper.measureText(t, {});
  340. if (tw !== twprev) {
  341. this.parsed.setSettings({testWidth: tw});
  342. this.draw();
  343. twprev = tw;
  344. }
  345. await utils.sleep(100);
  346. }
  347. } finally {
  348. this.checkingFont = false;
  349. }
  350. }
  351. }
  352. loadSettings() {
  353. (async() => {
  354. let fontName = this.fontName;
  355. this.getSettings();
  356. await this.calcPropsAndLoadFonts(fontName == this.fontName);
  357. })();
  358. }
  359. showBook() {
  360. this.$refs.main.focus();
  361. this.toggleLayout = false;
  362. this.updateLayout();
  363. this.book = null;
  364. this.meta = null;
  365. this.parsed = null;
  366. this.linesUp = null;
  367. this.linesDown = null;
  368. this.statusBarMessage = '';
  369. this.getSettings();
  370. this.calcDrawProps();
  371. this.draw();// пока не загрузили, очистим канвас
  372. if (this.lastBook) {
  373. (async() => {
  374. try {
  375. //подождем ленивый парсинг
  376. this.stopLazyParse = true;
  377. while (this.doingLazyParse) await utils.sleep(10);
  378. const isParsed = await bookManager.hasBookParsed(this.lastBook);
  379. if (!isParsed) {
  380. return;
  381. }
  382. this.book = await bookManager.getBook(this.lastBook);
  383. this.meta = bookManager.metaOnly(this.book);
  384. const bt = utils.getBookTitle(this.meta.fb2);
  385. this.title = bt.fullTitle;
  386. this.$root.setAppTitle(this.title);
  387. this.parsed = this.book.parsed;
  388. this.page1 = null;
  389. this.page2 = null;
  390. this.statusBar = null;
  391. await this.stopTextScrolling();
  392. await this.calcPropsAndLoadFonts();
  393. this.refreshTime();
  394. if (this.lazyParseEnabled)
  395. this.lazyParsePara();
  396. } catch (e) {
  397. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  398. }
  399. })();
  400. }
  401. }
  402. updateLayout() {
  403. if (this.inAnimation) {
  404. this.$refs.scrollBox1.style.visibility = 'visible';
  405. this.$refs.scrollBox2.style.visibility = 'visible';
  406. } else if (this.toggleLayout) {
  407. this.$refs.scrollBox1.style.visibility = 'visible';
  408. this.$refs.scrollBox2.style.visibility = 'hidden';
  409. } else {
  410. this.$refs.scrollBox1.style.visibility = 'hidden';
  411. this.$refs.scrollBox2.style.visibility = 'visible';
  412. }
  413. }
  414. setBackground() {
  415. if (this.wallpaperIgnoreStatusBar) {
  416. this.background = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  417. ` background-color: ${this.backgroundColor}">` +
  418. `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  419. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  420. `</div>` +
  421. `</div>`;
  422. } else {
  423. this.background = `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  424. ` background-color: ${this.backgroundColor}"></div>`;
  425. }
  426. }
  427. async onResize() {
  428. try {
  429. this.calcDrawProps();
  430. this.setBackground();
  431. this.draw();
  432. } catch (e) {
  433. //
  434. }
  435. }
  436. get settings() {
  437. return this.$store.state.reader.settings;
  438. }
  439. get font() {
  440. return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px '${this.fontName}'`;
  441. }
  442. onPage1TransitionEnd() {
  443. if (this.resolveTransition1Finish)
  444. this.resolveTransition1Finish();
  445. }
  446. onPage2TransitionEnd() {
  447. if (this.resolveTransition2Finish)
  448. this.resolveTransition2Finish();
  449. }
  450. startSearch(needle) {
  451. this.drawHelper.needle = needle;
  452. this.drawHelper.searching = true;
  453. this.draw();
  454. }
  455. stopSearch() {
  456. this.drawHelper.searching = false;
  457. this.draw();
  458. }
  459. generateWaitingFunc(waitingHandlerName, stopPropertyName) {
  460. const func = (timeout) => {
  461. return new Promise((resolve, reject) => { (async() => {
  462. this[waitingHandlerName] = resolve;
  463. let wait = (timeout + 201)/100;
  464. while (wait > 0 && !this[stopPropertyName]) {
  465. wait--;
  466. await utils.sleep(100);
  467. }
  468. resolve();
  469. })().catch(reject); });
  470. };
  471. return func;
  472. }
  473. async startTextScrolling() {
  474. if (this.doingScrolling || !this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1 ||
  475. this.linesDown.length <= this.pageLineCount || this.dualPageMode) {
  476. this.doStopScrolling();
  477. return;
  478. }
  479. //ждем анимацию
  480. while (this.inAnimation) await utils.sleep(10);
  481. this.stopScrolling = false;
  482. this.doingScrolling = true;
  483. const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling');
  484. if (!this.toggleLayout)
  485. this.page1 = this.page2;
  486. this.toggleLayout = true;
  487. await this.$nextTick();
  488. await utils.sleep(50);
  489. this.cachedPos = -1;
  490. this.draw();
  491. const page = this.$refs.scrollingPage1;
  492. let i = 0;
  493. while (!this.stopScrolling) {
  494. page.style.transition = `${this.scrollingDelay}ms ${this.scrollingType}`;
  495. page.style.transform = `translateY(-${this.lineHeight}px)`;
  496. if (i > 0) {
  497. this.doDown();
  498. if (this.linesDown.length <= this.pageLineCount + 1) {
  499. this.stopScrolling = true;
  500. }
  501. }
  502. await transitionFinish(this.scrollingDelay);
  503. page.style.transition = '';
  504. page.style.transform = 'none';
  505. page.offsetHeight;
  506. i++;
  507. }
  508. this.resolveTransition1Finish = null;
  509. this.doingScrolling = false;
  510. this.doStopScrolling();
  511. this.draw();
  512. }
  513. async stopTextScrolling() {
  514. this.stopScrolling = true;
  515. const page = this.$refs.scrollingPage1;
  516. page.style.transition = '';
  517. page.style.transform = 'none';
  518. page.offsetHeight;
  519. while (this.doingScrolling) await utils.sleep(10);
  520. }
  521. draw() {
  522. //scrolling
  523. if (this.doingScrolling) {
  524. this.currentAnimation = '';
  525. if (this.cachedPos == this.bookPos) {
  526. this.linesDown = this.linesCached.linesDown;
  527. this.linesUp = this.linesCached.linesUp;
  528. this.page1 = this.pageCached;
  529. } else {
  530. const lines = this.getLines(this.bookPos);
  531. this.linesDown = lines.linesDown;
  532. this.linesUp = lines.linesUp;
  533. this.page1 = this.drawHelper.drawPage(lines.linesDown, true);
  534. }
  535. //caching next
  536. if (this.cachedPageTimer)
  537. clearTimeout(this.cachedPageTimer);
  538. this.cachedPageTimer = setTimeout(() => {
  539. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  540. this.cachedPos = this.linesDown[1].begin;
  541. this.linesCached = this.getLines(this.cachedPos);
  542. this.pageCached = this.drawHelper.drawPage(this.linesCached.linesDown, true);
  543. }
  544. this.cachedPageTimer = null;
  545. }, 20);
  546. this.debouncedDrawStatusBar();
  547. return;
  548. }
  549. //check
  550. if (this.w < minLayoutWidth) {
  551. this.page1 = null;
  552. this.page2 = null;
  553. this.statusBar = null;
  554. return;
  555. }
  556. if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
  557. this.doEnd(true, false);
  558. return;
  559. }
  560. //fast draw prepared
  561. if (!this.pageChangeAnimation && this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
  562. this.toggleLayout = !this.toggleLayout;
  563. this.linesDown = this.linesDownNext;
  564. this.linesUp = this.linesUpNext;
  565. } else {//normal debounced draw
  566. const lines = this.getLines(this.bookPos);
  567. this.linesDown = lines.linesDown;
  568. this.linesUp = lines.linesUp;
  569. this.debouncedUpdatePage(lines.linesDown);
  570. }
  571. this.pagePrepared = false;
  572. if (!this.pageChangeAnimation)
  573. this.debouncedPrepareNextPage();
  574. this.debouncedDrawStatusBar();
  575. this.debouncedDrawPageDividerAndOrnament();
  576. if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount) {
  577. this.doEnd(true, false);
  578. return;
  579. }
  580. }
  581. onPage1AnimationEnd() {
  582. if (this.resolveAnimation1Finish)
  583. this.resolveAnimation1Finish();
  584. }
  585. onPage2AnimationEnd() {
  586. if (this.resolveAnimation2Finish)
  587. this.resolveAnimation2Finish();
  588. }
  589. async doPageAnimation() {
  590. if (this.currentAnimation && !this.inAnimation) {
  591. this.inAnimation = true;
  592. const animation1Finish = this.generateWaitingFunc('resolveAnimation1Finish', 'stopAnimation');
  593. const animation2Finish = this.generateWaitingFunc('resolveAnimation2Finish', 'stopAnimation');
  594. const transition1Finish = this.generateWaitingFunc('resolveTransition1Finish', 'stopAnimation');
  595. const transition2Finish = this.generateWaitingFunc('resolveTransition2Finish', 'stopAnimation');
  596. const duration = Math.round(3000*(1 - this.pageChangeAnimationSpeed/100));
  597. let page1 = this.$refs.scrollingPage1;
  598. let page2 = this.$refs.scrollingPage2;
  599. switch (this.currentAnimation) {
  600. case 'thaw':
  601. await this.drawHelper.doPageAnimationThaw(page1, page2,
  602. duration, this.pageChangeDirectionDown, animation1Finish);
  603. break;
  604. case 'blink':
  605. await this.drawHelper.doPageAnimationBlink(page1, page2,
  606. duration, this.pageChangeDirectionDown, animation1Finish, animation2Finish);
  607. break;
  608. case 'rightShift':
  609. await this.drawHelper.doPageAnimationRightShift(page1, page2,
  610. duration, this.pageChangeDirectionDown, transition1Finish);
  611. break;
  612. case 'downShift':
  613. page1.style.height = this.scrollHeight + 'px';
  614. page2.style.height = this.scrollHeight + 'px';
  615. await this.drawHelper.doPageAnimationDownShift(page1, page2,
  616. duration, this.pageChangeDirectionDown, transition1Finish);
  617. page1.style.height = this.scrollHeight + this.lineHeight + 'px';
  618. page2.style.height = this.scrollHeight + this.lineHeight + 'px';
  619. break;
  620. case 'rotate':
  621. await this.drawHelper.doPageAnimationRotate(page1, page2,
  622. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish);
  623. break;
  624. case 'flip':
  625. await this.drawHelper.doPageAnimationFlip(page1, page2,
  626. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish, this.backgroundColor);
  627. break;
  628. }
  629. this.resolveAnimation1Finish = null;
  630. this.resolveAnimation2Finish = null;
  631. this.resolveTransition1Finish = null;
  632. this.resolveTransition2Finish = null;
  633. page1.style.animation = '';
  634. page2.style.animation = '';
  635. page1.style.transition = '';
  636. page1.style.transform = 'none';
  637. page1.offsetHeight;
  638. page2.style.transition = '';
  639. page2.style.transform = 'none';
  640. page2.offsetHeight;
  641. this.currentAnimation = '';
  642. this.pageChangeDirectionDown = false;//true только если PgDown
  643. this.inAnimation = false;
  644. this.stopAnimation = false;
  645. }
  646. }
  647. getLines(bookPos) {
  648. if (!this.parsed || this.pageLineCount < 1)
  649. return {};
  650. return {
  651. linesDown: this.parsed.getLines(bookPos, 2*this.pageLineCount),
  652. linesUp: this.parsed.getLines(bookPos, -2*this.pageLineCount)
  653. };
  654. }
  655. drawStatusBar(message) {
  656. if (this.w < minLayoutWidth) {
  657. this.statusBar = null;
  658. return;
  659. }
  660. if (this.showStatusBar && this.linesDown && this.pageLineCount > 0) {
  661. const lines = this.linesDown;
  662. let i = this.pageLineCount;
  663. if (this.keepLastToFirst)
  664. i--;
  665. i = (i > lines.length - 1 ? lines.length - 1 : i);
  666. if (i >= 0) {
  667. if (!message)
  668. message = this.statusBarMessage;
  669. if (!message)
  670. message = this.title;
  671. //check image num
  672. let imageNum = 0;
  673. const len = (lines.length > 2 ? 2 : lines.length);
  674. loop:
  675. for (let j = 0; j < len; j++) {
  676. const line = lines[j];
  677. for (const part of line.parts) {
  678. if (part.image) {
  679. imageNum = part.image.num;
  680. break loop;
  681. }
  682. }
  683. }
  684. //drawing
  685. this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight,
  686. lines[i].end, this.parsed.textLength, message, imageNum, this.parsed.images.length);
  687. this.bookPosSeen = lines[i].end;
  688. }
  689. } else {
  690. this.statusBar = '';
  691. }
  692. }
  693. drawPageDividerAndOrnament() {
  694. if (this.dualPageMode) {
  695. this.pageDivider = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  696. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  697. `<div class="fit row justify-center items-center no-wrap">` +
  698. `<div style="height: ${Math.round(this.scrollHeight*this.dualDivHeight/100)}px; width: ${this.dualDivWidth}px; ` +
  699. `box-shadow: 0 0 ${this.dualDivShadowWidth}px ${this.dualDivRgbaColor}; ` +
  700. `background-image: url(&quot;data:image/svg+xml;utf8,<svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'>` +
  701. `<line x1='${this.dualDivWidth/2}' y1='0' x2='${this.dualDivWidth/2}' y2='100%' stroke='${this.dualDivRgbaColor}' ` +
  702. `stroke-width='${this.dualDivWidth}' stroke-dasharray='${this.dualDivStrokeFill} ${this.dualDivStrokeGap}'/>` +
  703. `</svg>&quot;);">` +
  704. `</div>` +
  705. `</div>` +
  706. `</div>`;
  707. } else {
  708. this.pageDivider = null;
  709. }
  710. }
  711. blinkCachedLoadMessage(state) {
  712. if (state === 'finish') {
  713. this.statusBarMessage = '';
  714. } else if (state) {
  715. this.statusBarMessage = 'Книга загружена из кэша';
  716. } else {
  717. this.statusBarMessage = ' ';
  718. }
  719. this.drawStatusBar();
  720. }
  721. async lazyParsePara() {
  722. if (!this.parsed || this.doingLazyParse)
  723. return;
  724. this.doingLazyParse = true;
  725. let j = 0;
  726. let k = 0;
  727. let prevPerc = 0;
  728. this.stopLazyParse = false;
  729. for (let i = 0; i < this.parsed.para.length; i++) {
  730. j++;
  731. if (j > 1) {
  732. await utils.sleep(1);
  733. j = 0;
  734. }
  735. if (this.stopLazyParse)
  736. break;
  737. this.parsed.parsePara(i);
  738. k++;
  739. if (k > 100) {
  740. let perc = Math.round(i/this.parsed.para.length*100);
  741. if (perc != prevPerc)
  742. this.drawStatusBar(`Обработка текста ${perc}%`);
  743. prevPerc = perc;
  744. k = 0;
  745. }
  746. }
  747. this.drawStatusBar();
  748. this.doingLazyParse = false;
  749. }
  750. async refreshTime() {
  751. if (!this.timeRefreshing) {
  752. this.timeRefreshing = true;
  753. await utils.sleep(60*1000);
  754. if (this.book && this.parsed.textLength) {
  755. this.debouncedDrawStatusBar();
  756. }
  757. this.timeRefreshing = false;
  758. this.refreshTime();
  759. }
  760. }
  761. prepareNextPage() {
  762. // подготовка следующей страницы заранее
  763. if (!this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1)
  764. return;
  765. let i = this.pageLineCount;
  766. if (this.keepLastToFirst)
  767. i--;
  768. if (i >= 0 && this.linesDown.length > i) {
  769. this.bookPosPrepared = this.linesDown[i].begin;
  770. const lines = this.getLines(this.bookPosPrepared);
  771. this.linesDownNext = lines.linesDown;
  772. this.linesUpNext = lines.linesUp;
  773. if (this.toggleLayout)
  774. this.page2 = this.drawHelper.drawPage(lines.linesDown);//наоборот
  775. else
  776. this.page1 = this.drawHelper.drawPage(lines.linesDown);
  777. this.pagePrepared = true;
  778. }
  779. }
  780. doDown() {
  781. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  782. this.userBookPosChange = true;
  783. this.bookPos = this.linesDown[1].begin;
  784. }
  785. }
  786. doUp() {
  787. if (this.linesUp && this.linesUp.length > 1 && this.pageLineCount > 0) {
  788. this.userBookPosChange = true;
  789. this.bookPos = this.linesUp[1].begin;
  790. }
  791. }
  792. doPageDown() {
  793. if (this.linesDown && this.pageLineCount > 0) {
  794. let i = this.pageLineCount;
  795. if (this.keepLastToFirst)
  796. i--;
  797. if (i >= 0 && this.linesDown.length >= 2*i + (this.keepLastToFirst ? 1 : 0)) {
  798. this.currentAnimation = this.pageChangeAnimation;
  799. this.pageChangeDirectionDown = true;
  800. this.userBookPosChange = true;
  801. this.bookPos = this.linesDown[i].begin;
  802. } else
  803. this.doEnd();
  804. }
  805. }
  806. doPageUp() {
  807. if (this.linesUp && this.pageLineCount > 0) {
  808. let i = this.pageLineCount;
  809. if (this.keepLastToFirst)
  810. i--;
  811. i = (i > this.linesUp.length - 1 ? this.linesUp.length - 1 : i);
  812. if (i >= 0 && this.linesUp.length > i) {
  813. this.currentAnimation = this.pageChangeAnimation;
  814. this.pageChangeDirectionDown = false;
  815. this.userBookPosChange = true;
  816. this.bookPos = this.linesUp[i].begin;
  817. }
  818. }
  819. }
  820. doHome() {
  821. this.currentAnimation = this.pageChangeAnimation;
  822. this.pageChangeDirectionDown = false;
  823. this.userBookPosChange = true;
  824. this.bookPos = 0;
  825. }
  826. doEnd(noAni, isUser = true) {
  827. if (this.parsed.para.length && this.pageLineCount > 0) {
  828. let i = this.parsed.para.length - 1;
  829. let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
  830. const lines = this.parsed.getLines(lastPos, -this.pageLineCount);
  831. if (lines) {
  832. i = this.pageLineCount - 1;
  833. i = (i > lines.length - 1 ? lines.length - 1 : i);
  834. if (!noAni)
  835. this.currentAnimation = this.pageChangeAnimation;
  836. this.pageChangeDirectionDown = true;
  837. this.userBookPosChange = isUser;
  838. this.bookPos = lines[i].begin;
  839. }
  840. }
  841. }
  842. doToolBarToggle(event) {
  843. this.$emit('do-action', {action: 'switchToolbar', event});
  844. }
  845. doScrollingToggle() {
  846. this.$emit('do-action', {action: 'scrolling', event});
  847. }
  848. doFullScreenToggle() {
  849. this.$emit('do-action', {action: 'fullScreen', event});
  850. }
  851. doStopScrolling() {
  852. this.$emit('do-action', {action: 'stopScrolling', event});
  853. }
  854. async doFontSizeInc() {
  855. if (!this.settingsChanging) {
  856. this.settingsChanging = true;
  857. const newSize = (this.settings.fontSize + 1 < 200 ? this.settings.fontSize + 1 : 100);
  858. this.commit('reader/setSettings', {fontSize: newSize});
  859. await utils.sleep(50);
  860. this.settingsChanging = false;
  861. }
  862. }
  863. async doFontSizeDec() {
  864. if (!this.settingsChanging) {
  865. this.settingsChanging = true;
  866. const newSize = (this.settings.fontSize - 1 > 5 ? this.settings.fontSize - 1 : 5);
  867. this.commit('reader/setSettings', {fontSize: newSize});
  868. await utils.sleep(50);
  869. this.settingsChanging = false;
  870. }
  871. }
  872. async doScrollingSpeedUp() {
  873. if (!this.settingsChanging) {
  874. this.settingsChanging = true;
  875. const newDelay = (this.settings.scrollingDelay - 50 > 1 ? this.settings.scrollingDelay - 50 : 1);
  876. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  877. await utils.sleep(50);
  878. this.settingsChanging = false;
  879. }
  880. }
  881. async doScrollingSpeedDown() {
  882. if (!this.settingsChanging) {
  883. this.settingsChanging = true;
  884. const newDelay = (this.settings.scrollingDelay + 50 < 10000 ? this.settings.scrollingDelay + 50 : 10000);
  885. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  886. await utils.sleep(50);
  887. this.settingsChanging = false;
  888. }
  889. }
  890. async startClickRepeat(pointX, pointY) {
  891. this.repX = pointX;
  892. this.repY = pointY;
  893. if (!this.repInit && this.repDoing) {
  894. this.repInit = true;
  895. let delay = 400;
  896. while (this.repDoing) {
  897. this.handleClick(pointX, pointY);
  898. await utils.sleep(delay);
  899. if (delay > 15)
  900. delay *= 0.8;
  901. }
  902. this.repInit = false;
  903. }
  904. }
  905. endClickRepeat() {
  906. this.repDoing = false;
  907. }
  908. onTouchStart(event) {
  909. if (!this.$root.isMobileDevice)
  910. return;
  911. this.endClickRepeat();
  912. if (event.touches.length == 1) {
  913. const touch = event.touches[0];
  914. const rect = event.target.getBoundingClientRect();
  915. const x = touch.pageX - rect.left;
  916. const y = touch.pageY - rect.top;
  917. const hc = this.handleClick(x, y, new Set(['Menu']));
  918. if (hc) {
  919. if (hc != 'Menu') {
  920. this.repDoing = true;
  921. this.debouncedStartClickRepeat(x, y);
  922. } else {
  923. this.startTouch = {x, y};
  924. }
  925. }
  926. }
  927. }
  928. onTouchMove(event) {
  929. if (this.startTouch) {
  930. event.preventDefault();
  931. }
  932. }
  933. onTouchEnd(event) {
  934. if (!this.$root.isMobileDevice)
  935. return;
  936. this.endClickRepeat();
  937. if (event.changedTouches.length == 1) {
  938. const touch = event.changedTouches[0];
  939. const rect = event.target.getBoundingClientRect();
  940. const x = touch.pageX - rect.left;
  941. const y = touch.pageY - rect.top;
  942. if (this.startTouch) {
  943. const dy = this.startTouch.y - y;
  944. const dx = this.startTouch.x - x;
  945. const moveDelta = 30;
  946. const touchDelta = 15;
  947. if (dy > 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  948. //движение вверх
  949. this.doFullScreenToggle();
  950. } else if (dy < 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  951. //движение вниз
  952. this.doScrollingToggle();
  953. } else if (dx > 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  954. //движение влево
  955. this.doScrollingSpeedDown();
  956. } else if (dx < 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  957. //движение вправо
  958. this.doScrollingSpeedUp();
  959. } else if (Math.abs(dy) < touchDelta && Math.abs(dx) < touchDelta) {
  960. this.doToolBarToggle(event);
  961. }
  962. this.startTouch = null;
  963. }
  964. }
  965. }
  966. onTouchCancel() {
  967. if (!this.$root.isMobileDevice)
  968. return;
  969. this.endClickRepeat();
  970. }
  971. onMouseDown(event) {
  972. if (this.$root.isMobileDevice)
  973. return;
  974. this.endClickRepeat();
  975. if (event.button == 0) {
  976. const hc = this.handleClick(event.offsetX, event.offsetY);
  977. if (hc && hc != 'Menu') {
  978. this.repDoing = true;
  979. this.debouncedStartClickRepeat(event.offsetX, event.offsetY);
  980. }
  981. } else if (event.button == 1) {
  982. this.doScrollingToggle();
  983. } else if (event.button == 2) {
  984. this.doToolBarToggle(event);
  985. }
  986. }
  987. onMouseUp() {
  988. if (this.$root.isMobileDevice)
  989. return;
  990. this.endClickRepeat();
  991. }
  992. onMouseWheel(event) {
  993. if (this.$root.isMobileDevice)
  994. return;
  995. if (event.deltaY > 0) {
  996. this.doDown();
  997. } else if (event.deltaY < 0) {
  998. this.doUp();
  999. }
  1000. }
  1001. onStatusBarClick() {
  1002. const url = this.meta.url;
  1003. if (url && url.indexOf('disk://') != 0) {
  1004. window.open(url, '_blank');
  1005. } else {
  1006. this.$root.stdDialog.alert('Оригинал недоступен, т.к. файл книги был загружен с локального диска.', ' ', {color: 'info'});
  1007. }
  1008. }
  1009. getClickAction(pointX, pointY) {
  1010. const w = pointX/this.realWidth*100;
  1011. const h = pointY/this.realHeight*100;
  1012. let action = '';
  1013. loops: {
  1014. for (const x in clickMap) {
  1015. for (const y in clickMap[x]) {
  1016. if (w < x && h < y) {
  1017. action = clickMap[x][y];
  1018. break loops;
  1019. }
  1020. }
  1021. }
  1022. }
  1023. return action;
  1024. }
  1025. handleClick(pointX, pointY, exclude) {
  1026. const action = this.getClickAction(pointX, pointY);
  1027. if (!exclude || !exclude.has(action)) {
  1028. switch (action) {
  1029. case 'Down' ://Down
  1030. this.doDown();
  1031. break;
  1032. case 'Up' ://Up
  1033. this.doUp();
  1034. break;
  1035. case 'PgDown' ://PgDown
  1036. this.doPageDown();
  1037. break;
  1038. case 'PgUp' ://PgUp
  1039. this.doPageUp();
  1040. break;
  1041. case 'Menu' :
  1042. this.doToolBarToggle();
  1043. break;
  1044. default :
  1045. // Nothing
  1046. }
  1047. }
  1048. return action;
  1049. }
  1050. copyText(event) {
  1051. //все это для того, чтобы правильно расставить переносы \n при копировании текста
  1052. //прямо с текущей страницы
  1053. //подготовка, вытаскиваем весь текст страницы
  1054. const lines = this.getLines(this.bookPos);
  1055. const decodedLines = [];
  1056. for (const line of lines.linesDown) {
  1057. let lineText = '';
  1058. for (const part of line.parts) {
  1059. lineText += part.text;
  1060. }
  1061. decodedLines.push({text: he.decode(lineText), first: line.first});
  1062. }
  1063. let i = 0;
  1064. const findDecoded = (line) => {
  1065. for (let j = i; j < decodedLines.length; j++) {
  1066. const decoded = decodedLines[j];
  1067. if (decoded.text.indexOf(line) >= 0) {
  1068. i = j;
  1069. return decoded;
  1070. }
  1071. }
  1072. return;
  1073. }
  1074. const selection = document.getSelection();
  1075. const splitted = selection.toString().split(/[\n\r]/);
  1076. let filtered = '';
  1077. //формируем filtered, учитывая переносы из decodedLines
  1078. for (const line of splitted) {
  1079. const found = findDecoded(line);
  1080. if (found && found.first) {
  1081. filtered += (filtered ? '\n' : '') + line;
  1082. } else {
  1083. filtered += (filtered ? '\r ' : '') + line;
  1084. }
  1085. }
  1086. //маленькие хитрости, убираем переносы по слогам
  1087. filtered = filtered.replace(/-\r /g, '').replace(/\r /g, ' ');
  1088. event.clipboardData.setData('text/plain', filtered);
  1089. }
  1090. }
  1091. export default vueComponent(TextPage);
  1092. //-----------------------------------------------------------------------------
  1093. </script>
  1094. <style scoped>
  1095. .main {
  1096. flex: 1;
  1097. margin: 0;
  1098. padding: 0;
  1099. overflow: hidden;
  1100. position: relative;
  1101. min-width: 200px;
  1102. }
  1103. .layout {
  1104. margin: 0;
  1105. padding: 0;
  1106. position: absolute;
  1107. z-index: 10;
  1108. }
  1109. .over-hidden {
  1110. overflow: hidden;
  1111. }
  1112. .on-top {
  1113. z-index: 100;
  1114. }
  1115. .back {
  1116. z-index: 5;
  1117. }
  1118. .events {
  1119. z-index: 20;
  1120. background-color: rgba(0,0,0,0);
  1121. }
  1122. </style>