Skip to content

Commit

Permalink
feat: improve browser compatibility for TypeIt and object-fit (#293)
Browse files Browse the repository at this point in the history
* object-fit polyfill
* TypeIt 7.0.3 -> 6.5.1
  • Loading branch information
dillonzq authored Apr 30, 2020
1 parent 3096ff6 commit 3040ffa
Show file tree
Hide file tree
Showing 27 changed files with 65 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Thanks to the authors of following resources included in the theme:
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
* [clipboard.js](https://github.com/zenorocha/clipboard.js)
Expand Down
1 change: 1 addition & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ LoveIt 主题中用到了以下项目,感谢它们的作者:
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
* [clipboard.js](https://github.com/zenorocha/clipboard.js)
Expand Down
7 changes: 4 additions & 3 deletions assets/css/_core/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ body {
}
}

@import "../_partial/mask";
@include ms;
@include link(true, true);

@import "../_partial/mask";
@import "../_partial/icon";
@import "../_partial/details";
@import "../_partial/fixed-button";

a {
text-decoration: none;
img {
@include object-fit(contain);
}
12 changes: 12 additions & 0 deletions assets/css/_mixin/_compatibility.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,15 @@
-ms-line-break: $value;
line-break: $value;
}

@mixin ms {
input::-ms-clear {
display: none;
}
}

@mixin object-fit($value) {
-o-object-fit: $value;
object-fit: $value;
font-family: 'object-fit: #{$value};';
}
2 changes: 2 additions & 0 deletions assets/css/_mixin/_link.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@mixin link($light, $dark) {
a, a::before, a::after {
text-decoration: none;

color: if($light, $global-link-color, $single-link-color);

[theme=dark] & {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/_mixin/_summary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
height: 100%;
left: 0;
top: 0;
object-fit: cover;
@include object-fit(cover);
}

&:hover {
Expand Down
2 changes: 1 addition & 1 deletion assets/css/_page/_single.scss
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
}

.lazyloading {
object-fit: none;
@include object-fit(none);
}

blockquote {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion assets/lib/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ [email protected] https://github.com/algolia/autocomplete.js
[email protected] https://lunrjs.com/
[email protected] https://github.com/algolia/algoliasearch-client-javascript
[email protected] https://github.com/aFarkas/lazysizes
[email protected] https://github.com/fregante/object-fit-images
[email protected] https://github.com/twitter/twemoji
[email protected] https://github.com/sachinchoolur/lightgallery.js
[email protected] https://github.com/sachinchoolur/lg-thumbnail.js
[email protected] https://github.com/sachinchoolur/lg-zoom.js
[email protected] https://github.com/zenorocha/clipboard.js
[email protected] https://github.com/ellisonleao/sharer.js
typeit@7.0.3 https://github.com/alexmacarthur/typeit
typeit@6.5.1 https://github.com/alexmacarthur/typeit
[email protected] https://katex.org/
[email protected] https://github.com/knsv/mermaid
[email protected] https://echarts.apache.org/
Expand Down
2 changes: 2 additions & 0 deletions assets/lib/object-fit-images/ofi.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions assets/lib/typeit/typeit.min.js

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions assets/svg/version.template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ enableEmoji = true
algoliasearchJS = ""
# [email protected] https://github.com/aFarkas/lazysizes
lazysizesJS = ""
# [email protected] https://github.com/fregante/object-fit-images
objectFitImagesJS = ""
# [email protected] https://github.com/twitter/twemoji
twemojiJS = ""
# [email protected] https://github.com/sachinchoolur/lightgallery.js
Expand All @@ -960,7 +962,7 @@ enableEmoji = true
clipboardJS = ""
# [email protected] https://github.com/ellisonleao/sharer.js
sharerJS = ""
# typeit@7.0.3 https://github.com/alexmacarthur/typeit
# typeit@6.5.1 https://github.com/alexmacarthur/typeit
typeitJS = ""
# [email protected] https://katex.org/
katexCSS = ""
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/about.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Thanks to the authors of following resources included in the theme:
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
* [clipboard.js](https://github.com/zenorocha/clipboard.js)
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/about.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Thanks to the authors of following resources included in the theme:
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
* [clipboard.js](https://github.com/zenorocha/clipboard.js)
Expand Down
1 change: 1 addition & 0 deletions exampleSite/content/about.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ LoveIt 主题中用到了以下项目,感谢它们的作者:
* [Lunr.js](https://lunrjs.com/)
* [algoliasearch](https://github.com/algolia/algoliasearch-client-javascript)
* [lazysizes](https://github.com/aFarkas/lazysizes)
* [object-fit-images](https://github.com/fregante/object-fit-images)
* [Twemoji](https://github.com/twitter/twemoji)
* [lightgallery.js](https://github.com/sachinchoolur/lightgallery.js)
* [clipboard.js](https://github.com/zenorocha/clipboard.js)
Expand Down
4 changes: 3 additions & 1 deletion exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ Please open the code block below to view the complete sample configuration :(far
algoliasearchJS = ""
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
lazysizesJS = ""
# {{< version 0.2.3 >}} {{< link "https://github.com/fregante/object-fit-images" "object-fit-images" >}}@3.2.4
objectFitImagesJS = ""
# {{< version 0.2.0 >}} {{< link "https://github.com/twitter/twemoji" "twemoji" >}}@12.1.5
twemojiJS = ""
# {{< link "https://github.com/sachinchoolur/lightgallery.js" "lightgallery.js" >}}@1.1.3
Expand All @@ -600,7 +602,7 @@ Please open the code block below to view the complete sample configuration :(far
clipboardJS = ""
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer.js" >}}@0.4.0
sharerJS = ""
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@7.0.3
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@6.5.1
typeitJS = ""
# {{< link "https://github.com/KaTeX/KaTeX" "katex" >}}@0.11.1
katexCSS = ""
Expand Down
4 changes: 3 additions & 1 deletion exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ Please open the code block below to view the complete sample configuration :(far
algoliasearchJS = ""
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
lazysizesJS = ""
# {{< version 0.2.3 >}} {{< link "https://github.com/fregante/object-fit-images" "object-fit-images" >}}@3.2.4
objectFitImagesJS = ""
# {{< version 0.2.0 >}} {{< link "https://github.com/twitter/twemoji" "twemoji" >}}@12.1.5
twemojiJS = ""
# {{< link "https://github.com/sachinchoolur/lightgallery.js" "lightgallery.js" >}}@1.1.3
Expand All @@ -605,7 +607,7 @@ Please open the code block below to view the complete sample configuration :(far
clipboardJS = ""
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer.js" >}}@0.4.0
sharerJS = ""
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@7.0.3
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@6.5.1
typeitJS = ""
# {{< link "https://github.com/KaTeX/KaTeX" "katex" >}}@0.11.1
katexCSS = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ hugo
algoliasearchJS = ""
# {{< link "https://github.com/aFarkas/lazysizes" "lazysizes" >}}@5.2.0
lazysizesJS = ""
# {{< version 0.2.3 >}} {{< link "https://github.com/fregante/object-fit-images" "object-fit-images" >}}@3.2.4
objectFitImagesJS = ""
# {{< version 0.2.0 >}} {{< link "https://github.com/twitter/twemoji" "twemoji" >}}@12.1.5
twemojiJS = ""
# {{< link "https://github.com/sachinchoolur/lightgallery.js" "lightgallery.js" >}}@1.1.3
Expand All @@ -603,7 +605,7 @@ hugo
clipboardJS = ""
# {{< link "https://github.com/ellisonleao/sharer.js" "sharer.js" >}}@0.4.0
sharerJS = ""
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@7.0.3
# {{< link "https://github.com/alexmacarthur/typeit" "typeit" >}}@6.5.1
typeitJS = ""
# {{< link "https://github.com/KaTeX/KaTeX" "katex" >}}@0.11.1
katexCSS = ""
Expand Down
Binary file modified exampleSite/static/images/Apple-Devices-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/Apple-Devices-Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
{{- $source := $cdn.lazysizesJS | default "lib/lazysizes/lazysizes.min.js" -}}
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}

{{- /* object-fit-images */ -}}
{{- $source := $cdn.objectFitImagesJS | default "lib/object-fit-images/ofi.min.js" -}}
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}

{{- /* twemoji */ -}}
{{- if $params.twemoji -}}
{{- $source := $cdn.twemojiJS | default "lib/twemoji/twemoji.min.js" -}}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions src/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Theme {
this.resizeEventSet = new Set();
this.switchThemeEventSet = new Set();
this.clickMaskEventSet = new Set();
if (objectFitImages) objectFitImages();
}

initSVGIcon() {
Expand All @@ -56,7 +57,7 @@ class Theme {
if ($titleElements.length) $svg.removeChild($titleElements[0]);
$icon.parentElement.replaceChild($svg, $icon);
})
.catch(console.error.bind(console));
.catch(err => { console.error(err); });
});
}

Expand Down Expand Up @@ -586,12 +587,7 @@ class Theme {
}

initSmoothScroll() {
if ((!this.util.isMobile() && this.config.headerMode.desktop === 'normal')
|| (this.util.isMobile() && this.config.headerMode.mobile === 'normal')) {
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true});
} else {
new SmoothScroll('[href^="#"]', {speed: 300, speedAsDuration: true, header: '#header-desktop'});
}
if (SmoothScroll) new SmoothScroll('[href^="#"]', { speed: 300, speedAsDuration: true, header: '#header-desktop' });
}

onScroll() {
Expand Down

0 comments on commit 3040ffa

Please sign in to comment.