Commit 02d7f99f authored by Alexander Trofimov's avatar Alexander Trofimov Committed by GitHub

Merge pull request #189 from ONLYOFFICE/feature/refactoring-scroll

Feature/refactoring scroll
parents 6fec0fb1 6f3df233
......@@ -57,12 +57,8 @@
vscrollStep: 10,
hscrollStep: 10,
scrollTimeout: 20,
showArrows: true,//показывать или нет стрелки у скролла
//scrollBackgroundColor:"#DDDDDD",//цвет фона скролла
//scrollerColor:"#EDEDED",//цвет ползунка скрола
isViewerMode: false,
wheelScrollLines: 3,
isNeedInvertOnActive: false
wheelScrollLinesV: 3
};
this.view = undefined;
......@@ -352,7 +348,7 @@
};
asc_CEventsController.prototype._createScrollBars = function () {
var self = this, opt = this.settings;
var self = this, settings, opt = this.settings;
// vertical scroll bar
this.vsb = document.createElement('div');
......@@ -362,9 +358,14 @@
this.vsbHSt = document.getElementById("ws-v-scroll-helper").style;
if (!this.vsbApi) {
this.vsbApi = new AscCommon.ScrollObject(this.vsb.id, opt);
settings = new AscCommon.ScrollSettings();
settings.vscrollStep = opt.vscrollStep;
settings.hscrollStep = opt.hscrollStep;
settings.wheelScrollLines = opt.wheelScrollLinesV;
this.vsbApi = new AscCommon.ScrollObject(this.vsb.id, settings);
this.vsbApi.bind("scrollvertical", function(evt) {
self.handlers.trigger("scrollY", evt.scrollPositionY / opt.vscrollStep);
self.handlers.trigger("scrollY", evt.scrollPositionY / self.settings.vscrollStep);
});
this.vsbApi.bind("scrollVEnd", function(evt) {
self.handlers.trigger("addRow");
......@@ -385,9 +386,13 @@
this.hsbHSt = document.getElementById("ws-h-scroll-helper").style;
if (!this.hsbApi) {
this.hsbApi = new AscCommon.ScrollObject(this.hsb.id, $.extend(true, {}, opt, {wheelScrollLines: 1}));
settings = new AscCommon.ScrollSettings();
settings.vscrollStep = opt.vscrollStep;
settings.hscrollStep = opt.hscrollStep;
this.hsbApi = new AscCommon.ScrollObject(this.hsb.id, settings);
this.hsbApi.bind("scrollhorizontal",function(evt) {
self.handlers.trigger("scrollX", evt.scrollPositionX / opt.hscrollStep);
self.handlers.trigger("scrollX", evt.scrollPositionX / self.settings.hscrollStep);
});
this.hsbApi.bind("scrollHEnd",function(evt) {
self.handlers.trigger("addColumn");
......@@ -1641,7 +1646,7 @@
self.scrollHorizontal(deltaX, event);
}
if (deltaY) {
deltaY = Math.sign(deltaY) * Math.ceil(Math.abs(deltaY * self.settings.wheelScrollLines / 3));
deltaY = Math.sign(deltaY) * Math.ceil(Math.abs(deltaY * self.settings.wheelScrollLinesV / 3));
self.scrollVertical(deltaY, event);
}
self._onMouseMove(event);
......
......@@ -209,5 +209,5 @@ AscBrowser.convertToRetinaValue = function(value, isScale)
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].AscBrowser = AscBrowser; // ToDo убрать window['AscBrowser']
window['AscCommon'].AscBrowser = AscBrowser;
})(window);
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3472,7 +3472,7 @@ function CThumbnailsManager()
}
this.initEvents2MobileAdvances();
}
};
this.initEvents2MobileAdvances = function()
{
......@@ -3495,7 +3495,7 @@ function CThumbnailsManager()
oThis.onMouseUp(e.changedTouches[0]);
return false;
};
}
};
this.GetThumbnailPagePosition = function(pageIndex)
{
......@@ -3510,7 +3510,7 @@ function CThumbnailsManager()
H : drawRect.bottom - drawRect.top + 1
};
return _ret;
}
};
this.ConvertCoords = function(x, y, isPage, isFixed)
{
......@@ -3560,7 +3560,7 @@ function CThumbnailsManager()
}
}
return Pos;
}
};
this.ConvertCoords2 = function(x, y)
{
var Pos = {X : x, Y : y};
......@@ -3599,7 +3599,7 @@ function CThumbnailsManager()
}
return _MinPositionPage;
}
};
this.IsSlideHidden = function(aSelected){
var oPresentation = oThis.m_oWordControl.m_oLogicDocument;
......@@ -3775,7 +3775,7 @@ function CThumbnailsManager()
}
return false;
}
};
this.ShowPage = function(pageNum)
{
......@@ -3791,7 +3791,7 @@ function CThumbnailsManager()
{
this.m_oWordControl.m_oScrollThumbApi.scrollByY(y2 - this.m_oWordControl.m_oThumbnails.HtmlElement.height);
}
}
};
this.SelectPage = function(pageNum)
{
......@@ -3832,7 +3832,7 @@ function CThumbnailsManager()
}
}
}
}
};
this.ClearCacheAttack = function()
{
......@@ -3844,7 +3844,7 @@ function CThumbnailsManager()
}
this.m_bIsUpdate = true;
}
};
this.RecalculateAll = function()
{
this.SlideWidth = this.m_oWordControl.m_oLogicDocument.Width;
......@@ -3853,7 +3853,7 @@ function CThumbnailsManager()
this.CheckSizes();
this.ClearCacheAttack();
}
};
this.onMouseMove = function(e)
{
......@@ -3953,7 +3953,7 @@ function CThumbnailsManager()
}
oThis.m_oWordControl.m_oThumbnails.HtmlElement.style.cursor = cursor_moved;
}
};
this.CheckNeedAnimateScrolls = function(type)
{
......@@ -4001,16 +4001,16 @@ function CThumbnailsManager()
}
return;
}
}
};
this.OnScrollTrackTop = function()
{
oThis.m_oWordControl.m_oScrollThumbApi.scrollByY(-45);
}
};
this.OnScrollTrackBottom = function()
{
oThis.m_oWordControl.m_oScrollThumbApi.scrollByY(45);
}
};
this.onMouseUp = function(e, bIsWindow)
{
......@@ -4084,7 +4084,7 @@ function CThumbnailsManager()
oThis.MouseDownTrackPosition = -1;
oThis.onMouseMove(e);
}
};
this.onMouseLeave = function(e)
{
......@@ -4094,7 +4094,7 @@ function CThumbnailsManager()
oThis.m_arrPages[i].IsFocused = false;
}
oThis.OnUpdateOverlay();
}
};
this.onMouseWhell = function(e)
{
......@@ -4127,7 +4127,7 @@ function CThumbnailsManager()
else
e.returnValue = false;
return false;
}
};
// инициализация шрифта
this.SetFont = function(font)
......@@ -4152,7 +4152,7 @@ function CThumbnailsManager()
oFontStyle = FontStyle.FontStyleBoldItalic;
g_fontApplication.LoadFont(font.FontFamily.Name, AscCommon.g_font_loader, this.m_oFontManager, font.FontSize, oFontStyle, 96, 96);
}
};
this.Init = function()
{
......@@ -4216,7 +4216,7 @@ function CThumbnailsManager()
}
_ctx.putImageData(_data, 0, 0);
}
};
this.CheckSizes = function()
{
......@@ -4309,17 +4309,15 @@ function CThumbnailsManager()
nHeightPix += (this.SlidesCount - 1) * 3 * this.const_border_w;
// теперь нужно выставить размеры
var settings = {
showArrows : false,
animateScroll : false,
screenW : word_control.m_oThumbnails.HtmlElement.width,
screenH : word_control.m_oThumbnails.HtmlElement.height,
cornerRadius : 1,
slimScroll : true,
scrollBackgroundColor : GlobalSkin.BackgroundColorThumbnails,
scrollBackgroundColorHover : GlobalSkin.BackgroundColorThumbnails,
scrollBackgroundColorActive : GlobalSkin.BackgroundColorThumbnails
};
var settings = new AscCommon.ScrollSettings();
settings.showArrows = false;
settings.screenW = word_control.m_oThumbnails.HtmlElement.width;
settings.screenH = word_control.m_oThumbnails.HtmlElement.height;
settings.cornerRadius = 1;
settings.slimScroll = true;
settings.scrollBackgroundColor = GlobalSkin.BackgroundColorThumbnails;
settings.scrollBackgroundColorHover = GlobalSkin.BackgroundColorThumbnails;
settings.scrollBackgroundColorActive = GlobalSkin.BackgroundColorThumbnails;
document.getElementById('panel_right_scroll_thmbnl').style.height = parseInt(nHeightPix) + "px";
......@@ -4354,7 +4352,7 @@ function CThumbnailsManager()
this.CalculatePlaces();
this.m_bIsUpdate = true;
}
};
this.verticalScroll = function(sender, scrollPositionY, maxY, isAtTop, isAtBottom)
{
......@@ -4369,7 +4367,7 @@ function CThumbnailsManager()
if (!this.m_oWordControl.m_oApi.isMobileVersion)
this.SetFocusElement(FOCUS_OBJECT_THUMBNAILS);
}
};
this.CalculatePlaces = function()
{
......@@ -4446,7 +4444,7 @@ function CThumbnailsManager()
{
this.m_lDrawingEnd = this.SlidesCount - 1;
}
}
};
this.OnPaint = function()
{
......@@ -4530,7 +4528,7 @@ function CThumbnailsManager()
}
this.OnUpdateOverlay();
}
};
this.OnUpdateOverlay = function()
{
......@@ -4654,12 +4652,12 @@ function CThumbnailsManager()
(this.MouseTrackCommonImage.width + 1) >> 1, this.MouseTrackCommonImage.height);
}
}
}
};
this.FocusRectDraw = function(ctx, x, y, r, b)
{
ctx.rect(x - this.const_border_w, y, r - x + this.const_border_w, b - y);
}
};
this.FocusRectFlat = function(_color, ctx, x, y, r, b)
{
ctx.beginPath();
......@@ -4679,7 +4677,7 @@ function CThumbnailsManager()
ctx.stroke();
ctx.beginPath();
}
}
};
this.onCheckUpdate = function()
{
......@@ -4770,7 +4768,7 @@ function CThumbnailsManager()
this.OnPaint();
this.m_bIsUpdate = false;
}
};
this.SetFocusElement = function(type)
......@@ -4798,7 +4796,7 @@ function CThumbnailsManager()
default:
break;
}
}
};
this.GetSelectedSlidesRange = function()
{
......@@ -4816,7 +4814,7 @@ function CThumbnailsManager()
}
}
return {Min : _min, Max : _max};
}
};
this.GetSelectedArray = function()
{
......@@ -4830,7 +4828,7 @@ function CThumbnailsManager()
}
}
return _array;
}
};
this.CorrectShiftSelect = function(isTop, isEnd)
{
......@@ -4898,7 +4896,7 @@ function CThumbnailsManager()
this.OnUpdateOverlay();
this.ShowPage(_page);
}
};
this.onKeyDown = function(e)
{
......@@ -5302,7 +5300,7 @@ function CThumbnailsManager()
e.preventDefault();
return false;
}
};
}
function DrawBackground(graphics, unifill, w, h)
......@@ -5755,26 +5753,19 @@ function CNotesDrawer(page)
return;
var element = this.HtmlPage.m_oNotes.HtmlElement;
var settings = {
showArrows: true,
animateScroll: false,
screenW: element.width,
screenH: element.height,
screenAddW: 0,
screenAddH: 0,
vsscrollStep: 45,
hsscrollStep: 45,
contentW: 1,
contentH: 2 * this.OffsetY + ((height * g_dKoef_mm_to_pix) >> 0),
scrollerMinHeight: 5
};
var settings = new AscCommon.ScrollSettings();
settings.screenW = element.width;
settings.screenH = element.height;
settings.vsscrollStep = 45;
settings.hsscrollStep = 45;
settings.contentW = 1;
settings.contentH = 2 * this.OffsetY + ((height * g_dKoef_mm_to_pix) >> 0);
settings.scrollerMinHeight = 5;
if (this.HtmlPage.bIsRetinaSupport)
{
settings.screenW = AscCommon.AscBrowser.convertToRetinaValue(settings.screenW);
settings.screenH = AscCommon.AscBrowser.convertToRetinaValue(settings.screenH);
settings.screenAddH = AscCommon.AscBrowser.convertToRetinaValue(settings.screenAddH);
}
this.ScrollMax = Math.max(0, settings.contentH - settings.screenH);
......
......@@ -2747,23 +2747,15 @@ function CEditorPage(api)
}
};
this.UpdateScrolls = function()
this.CreateScrollSettings = function()
{
if (window["NATIVE_EDITOR_ENJINE"])
return;
var settings = {
showArrows : true,
animateScroll : false,
screenW : this.m_oEditor.HtmlElement.width,
screenH : this.m_oEditor.HtmlElement.height,
screenAddW : 0,
screenAddH : 0,
vsscrollStep : 45,
hsscrollStep : 45,
contentH : this.m_dDocumentHeight,
contentW : this.m_dDocumentWidth
};
var settings = new AscCommon.ScrollSettings();
settings.screenW = this.m_oEditor.HtmlElement.width;
settings.screenH = this.m_oEditor.HtmlElement.height;
settings.vscrollStep = 45;
settings.hscrollStep = 45;
settings.contentH = this.m_dDocumentHeight;
settings.contentW = this.m_dDocumentWidth;
if (this.m_bIsRuler)
{
......@@ -2774,13 +2766,21 @@ function CEditorPage(api)
{
settings.screenW = AscCommon.AscBrowser.convertToRetinaValue(settings.screenW);
settings.screenH = AscCommon.AscBrowser.convertToRetinaValue(settings.screenH);
settings.screenAddH = AscCommon.AscBrowser.convertToRetinaValue(settings.screenAddH);
}
return settings;
};
this.UpdateScrolls = function()
{
var settings;
if (window["NATIVE_EDITOR_ENJINE"])
return;
settings = this.CreateScrollSettings();
settings.alwaysVisible = true;
if (this.m_bIsHorScrollVisible)
{
settings.alwaysVisible = true;
if (this.m_oScrollHor_)
this.m_oScrollHor_.Repos(settings, true, undefined);//unbind("scrollhorizontal")
else
......@@ -2803,9 +2803,9 @@ function CEditorPage(api)
this.m_oScrollHorApi = this.m_oScrollHor_;
}
settings.alwaysVisible = undefined;
}
settings = this.CreateScrollSettings();
if (this.m_oScrollVer_)
{
this.m_oScrollVer_.Repos(settings, undefined, true);//unbind("scrollvertical")
......@@ -2813,9 +2813,7 @@ function CEditorPage(api)
else
{
this.m_oScrollVer_ = new AscCommon.ScrollObject("id_vertical_scroll",
settings
);
this.m_oScrollVer_ = new AscCommon.ScrollObject("id_vertical_scroll", settings);
this.m_oScrollVer_.onLockMouse = function(evt)
{
......
......@@ -830,7 +830,7 @@ function CEditorPage(api)
};
}
}
}
};
this.onButtonRulersClick = function()
{
......@@ -2450,7 +2450,7 @@ function CEditorPage(api)
global_keyboardEvent.CtrlKey = false;
global_keyboardEvent.ShiftKey = false;
global_keyboardEvent.AltGr = false;
}
};
this.onKeyPress = function(e)
{
if (AscCommon.g_clipboardBase.IsWorking())
......@@ -2576,29 +2576,30 @@ function CEditorPage(api)
}
};
this.UpdateScrolls = function()
this.CreateScrollSettings = function()
{
if (window["NATIVE_EDITOR_ENJINE"])
return;
var settings = {
showArrows : true,
animateScroll : false,
// scrollBackgroundColor: GlobalSkin.BackgroundScroll,
// scrollerColor:"#EDEDED",
screenW : this.m_oEditor.HtmlElement.width,
screenH : this.m_oEditor.HtmlElement.height,
vscrollStep : 45,
hscrollStep : 45,
isNeedInvertOnActive : GlobalSkin.isNeedInvertOnActive
};
var settings = new AscCommon.ScrollSettings();
settings.screenW = this.m_oEditor.HtmlElement.width;
settings.screenH = this.m_oEditor.HtmlElement.height;
settings.vscrollStep = 45;
settings.hscrollStep = 45;
settings.isNeedInvertOnActive = GlobalSkin.isNeedInvertOnActive;
if (this.bIsRetinaSupport)
{
settings.screenW = AscCommon.AscBrowser.convertToRetinaValue(settings.screenW);
settings.screenH = AscCommon.AscBrowser.convertToRetinaValue(settings.screenH);
}
return settings;
};
this.UpdateScrolls = function()
{
var settings;
if (window["NATIVE_EDITOR_ENJINE"])
return;
settings = this.CreateScrollSettings();
if (this.m_oScrollHor_)
this.m_oScrollHor_.Repos(settings, this.m_bIsHorScrollVisible);
else
......@@ -2609,18 +2610,19 @@ function CEditorPage(api)
{
AscCommon.check_MouseDownEvent(evt, true);
global_mouseEvent.LockMouse();
}
};
this.m_oScrollHor_.offLockMouse = function(evt)
{
AscCommon.check_MouseUpEvent(evt);
}
};
this.m_oScrollHor_.bind("scrollhorizontal", function(evt)
{
oThis.horizontalScroll(this, evt.scrollD, evt.maxScrollX);
})
});
this.m_oScrollHorApi = this.m_oScrollHor_;
}
settings = this.CreateScrollSettings();
if (this.m_oScrollVer_)
{
this.m_oScrollVer_.Repos(settings, undefined, true);
......@@ -2633,11 +2635,11 @@ function CEditorPage(api)
{
AscCommon.check_MouseDownEvent(evt, true);
global_mouseEvent.LockMouse();
}
};
this.m_oScrollVer_.offLockMouse = function(evt)
{
AscCommon.check_MouseUpEvent(evt);
}
};
this.m_oScrollVer_.bind("scrollvertical", function(evt)
{
oThis.verticalScroll(this, evt.scrollD, evt.maxScrollY);
......
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 to comment