mattermost-mobile/app/screens/post_options/post_options_utils.js
Saturnino Abril b153dd96a1
[MM-13412 & MM-13711] Allow showing of all post options if possible to fit 75% of the screen height (#2501)
* allow showing all options if possible to fit 60% of the screen height

* change max initial position from 60% to 70%

* fix broken UI of the bottom part of post options

* change to 75%
2019-01-30 01:07:58 +08:00

27 lines
1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export const OPTION_HEIGHT = 50;
const BOTTOM_HEIGHT = 18;
export const MAX_INITIAL_POSITION_MULTIPLIER = 0.75;
export function getInitialPosition(deviceHeight, marginFromTop) {
const computedSlidePanelHeight = deviceHeight - marginFromTop;
const maxInitialPosition = deviceHeight * MAX_INITIAL_POSITION_MULTIPLIER;
if (computedSlidePanelHeight <= maxInitialPosition) {
// Show all options to the user
return computedSlidePanelHeight;
}
const optionHeightWithBorder = OPTION_HEIGHT + 1;
// Partially show options to user with the first hidden option in mid appearance
// to indicate that are still option/s available on slide up
let adjustedInitialPosition = computedSlidePanelHeight - BOTTOM_HEIGHT - (optionHeightWithBorder / 2);
while (adjustedInitialPosition > maxInitialPosition) {
adjustedInitialPosition -= optionHeightWithBorder;
}
return adjustedInitialPosition;
}