Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make text animation more palatable on mobile #483

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions site/themes/dojo/layout/_partial/landingPage/upAndRunning.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@

requestAnimationFrame(animate);
}

var typing1Elem = document.querySelector('#upAndRunning-typing-1 .typed-text');
var fontSize = window.getComputedStyle(typing1Elem, null).getPropertyValue('font-size');

window.onresize = function() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this function was set to a local variable, it could be called above to set fontSize and would reduce duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fontSize = window.getComputedStyle(typing1Elem, null).getPropertyValue('font-size');
}

function updateTyping1Animations(percentCompletion) {
var width = calculateWidth(typing1Elem);
var typing = {
x1: 0, x2: 0.15,
y1: 0, y2: 365
y1: 0, y2: width
};
var fadeIn = {
x1: 0.15, x2: 0.2,
Expand All @@ -133,13 +139,14 @@
var typing2Elem = document.querySelector('#upAndRunning-typing-2 .typed-text');

function updateTyping2Animations(percentCompletion) {
var width = calculateWidth(typing1Elem);
var delayShow = {
x1: 0.25, x2: 0.26,
y1: 0, y2: 1
};
var typing = {
x1: 0.25, x2: 0.4,
y1: 0, y2: 350
y1: 0, y2: width
};
var fadeIn = {
x1: 0.4, x2: 0.45,
Expand Down Expand Up @@ -204,6 +211,13 @@
}
}

function calculateWidth(el) {
var textLen = typing1Elem.textContent.length;
var buffer = 5;
return (parseFloat(fontSize) * textLen) / 2 + buffer;
}

requestAnimationFrame(animate);

})();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ section.up-and-running {

@media screen and (max-width : $mobile-break) {
padding: 3vh 5vw;
width: 100%;
}

margin: auto;
Expand Down Expand Up @@ -60,6 +61,7 @@ section.up-and-running {
@media screen and (max-width : $mobile-break) {
font-size: 30px;
padding-right: 0.3em;
width: 100%;
}
}
&.typed-text {
Expand All @@ -77,6 +79,7 @@ section.up-and-running {

@media screen and (max-width : $mobile-break) {
margin-bottom: 10px;
font-size: $base-pre-font-size-mobile
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion site/themes/dojo/source/css/_util/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $global-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hel
$base-code-font-size: 0.85rem;
$base-code-color: #032f62;
$base-pre-font-size: 0.85rem;
$base-pre-font-size-mobile: 0.75rem;
$base-code-font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
$heading-font: 'Montserrat', sans-serif;
$base-heading-font-family: $heading-font;
Expand All @@ -61,4 +62,4 @@ $navbar-dropdown-nav-font-size: $navbar-nav-item-font-size;
$subnav-item-font-size: $navbar-nav-item-font-size;
$nav-primary-item-font-size: 0.95rem;
$navbar-dropdown-width: 165px;
$navbar-dropdown-margin: 0;
$navbar-dropdown-margin: 0;