Improved image loading
This commit is contained in:
parent
858aec9719
commit
35f694bcda
@ -3,7 +3,7 @@ component AnimeGrid(animeList []*arn.Anime, user *arn.User)
|
|||||||
each anime in animeList
|
each anime in animeList
|
||||||
.anime-grid-cell(data-added=(user != nil && user.AnimeList().Contains(anime.ID)))
|
.anime-grid-cell(data-added=(user != nil && user.AnimeList().Contains(anime.ID)))
|
||||||
a.ajax(href="/anime/" + toString(anime.ID))
|
a.ajax(href="/anime/" + toString(anime.ID))
|
||||||
img.anime-grid-image.lazy(data-src=anime.ImageLink("medium"), data-webp="true", data-color=anime.Image.AverageColor, alt=anime.Title.Romaji)
|
img.anime-grid-image.lazy(data-src=anime.ImageLink("medium"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.Romaji)
|
||||||
.anime-grid-title
|
.anime-grid-title
|
||||||
.anime-grid-title-text= anime.Title.ByUser(user)
|
.anime-grid-title-text= anime.Title.ByUser(user)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
|
|||||||
.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + item.AnimeID + "\"]")
|
.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + item.AnimeID + "\"]")
|
||||||
.anime-list-item-image-container
|
.anime-list-item-image-container
|
||||||
a.anime-list-item-image-link.ajax(href=item.Anime().Link())
|
a.anime-list-item-image-link.ajax(href=item.Anime().Link())
|
||||||
img.anime-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", alt=item.Anime().Title.ByUser(user))
|
img.anime-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", data-color=item.Anime().AverageColor(), alt=item.Anime().Title.ByUser(user))
|
||||||
|
|
||||||
.anime-list-item-name
|
.anime-list-item-name
|
||||||
a.ajax(href=item.Link(viewUser.Nick))= item.Anime().Title.ByUser(user)
|
a.ajax(href=item.Link(viewUser.Nick))= item.Anime().Title.ByUser(user)
|
||||||
|
@ -7,7 +7,7 @@ component SoundTrackContent(track *arn.SoundTrack)
|
|||||||
.soundtrack-content
|
.soundtrack-content
|
||||||
if track.MainAnime() != nil
|
if track.MainAnime() != nil
|
||||||
a.soundtrack-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
|
a.soundtrack-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
|
||||||
img.soundtrack-anime-image.lazy(data-src=track.MainAnime().ImageLink("medium"), data-webp="true", alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
|
img.soundtrack-anime-image.lazy(data-src=track.MainAnime().ImageLink("medium"), data-webp="true", data-color=track.MainAnime().AverageColor(), alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
|
||||||
|
|
||||||
SoundTrackMedia(track)
|
SoundTrackMedia(track)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.Sou
|
|||||||
component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
|
component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
|
||||||
.anime-header(data-id=anime.ID)
|
.anime-header(data-id=anime.ID)
|
||||||
a.anime-image-container.mountable(href=anime.ImageLink("original"), target="_blank")
|
a.anime-image-container.mountable(href=anime.ImageLink("original"), target="_blank")
|
||||||
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.Image.AverageColor, alt=anime.Title.ByUser(user))
|
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
.space
|
.space
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ component AnimeRelations(anime *arn.Anime, user *arn.User)
|
|||||||
.anime-relations
|
.anime-relations
|
||||||
each relation in anime.Relations().Items
|
each relation in anime.Relations().Items
|
||||||
a.anime-relation.mountable.ajax(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
|
a.anime-relation.mountable.ajax(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
|
||||||
img.anime-relation-image.lazy(data-src=relation.Anime().ImageLink("small"), data-webp="true", alt=relation.Anime().Title.ByUser(user))
|
img.anime-relation-image.lazy(data-src=relation.Anime().ImageLink("small"), data-webp="true", data-color=relation.Anime().AverageColor(), alt=relation.Anime().Title.ByUser(user))
|
||||||
.anime-relation-type= relation.HumanReadableType()
|
.anime-relation-type= relation.HumanReadableType()
|
||||||
.anime-relation-year
|
.anime-relation-year
|
||||||
if relation.Anime().StartDate != ""
|
if relation.Anime().StartDate != ""
|
||||||
|
@ -12,7 +12,7 @@ component Calendar(days []*utils.CalendarDay, user *arn.User)
|
|||||||
.calendar-entries
|
.calendar-entries
|
||||||
each entry in day.Entries
|
each entry in day.Entries
|
||||||
a.calendar-entry.mountable.ajax(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
|
a.calendar-entry.mountable.ajax(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
|
||||||
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", alt=entry.Anime.Title.ByUser(user))
|
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", data-color=entry.Anime.AverageColor(), alt=entry.Anime.Title.ByUser(user))
|
||||||
.calendar-entry-info
|
.calendar-entry-info
|
||||||
.calendar-entry-title= entry.Anime.Title.ByUser(user)
|
.calendar-entry-title= entry.Anime.Title.ByUser(user)
|
||||||
.calendar-entry-time-and-episode
|
.calendar-entry-time-and-episode
|
||||||
|
@ -14,7 +14,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
|
|||||||
.character-anime
|
.character-anime
|
||||||
each anime in characterAnime
|
each anime in characterAnime
|
||||||
a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.character-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.character-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
if len(quotes) >0
|
if len(quotes) >0
|
||||||
h3 Quotes
|
h3 Quotes
|
||||||
|
@ -43,7 +43,7 @@ component CompanyAnime(label string, animes []*arn.Anime, user *arn.User)
|
|||||||
.company-anime.mountable
|
.company-anime.mountable
|
||||||
each anime in animes
|
each anime in animes
|
||||||
a.company-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.company-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.company-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.company-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
component CompanyTabs(company *arn.Company, user *arn.User)
|
component CompanyTabs(company *arn.Company, user *arn.User)
|
||||||
.tabs
|
.tabs
|
||||||
|
@ -20,7 +20,7 @@ component CompareAnimeList(a *arn.User, b *arn.User, countA int, countB int, com
|
|||||||
tr.anime-list-item.mountable
|
tr.anime-list-item.mountable
|
||||||
td.anime-list-item-image-container
|
td.anime-list-item-image-container
|
||||||
a.ajax(href=comparison.Anime.Link())
|
a.ajax(href=comparison.Anime.Link())
|
||||||
img.anime-list-item-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
img.anime-list-item-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", data-color=comparison.Anime.AverageColor(), alt=comparison.Anime.Title.ByUser(user))
|
||||||
|
|
||||||
td.anime-list-item-name
|
td.anime-list-item-name
|
||||||
a.ajax(href=comparison.Anime.Link())= comparison.Anime.Title.ByUser(user)
|
a.ajax(href=comparison.Anime.Link())= comparison.Anime.Title.ByUser(user)
|
||||||
|
@ -12,4 +12,4 @@ component EditAnimeImages(anime *arn.Anime)
|
|||||||
InputImage("anime-image-input", "File", "/api/upload/anime/" + anime.ID + "/image")
|
InputImage("anime-image-input", "File", "/api/upload/anime/" + anime.ID + "/image")
|
||||||
|
|
||||||
.anime-image-container
|
.anime-image-container
|
||||||
img#anime-image-input-preview.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", alt="Anime image")
|
img#anime-image-input-preview.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.AverageColor(), alt="Anime image")
|
@ -8,7 +8,7 @@ component CompareMAL(comparisons []*utils.MALComparison, year string, status str
|
|||||||
.data-comparison.mountable
|
.data-comparison.mountable
|
||||||
.data-comparison-header
|
.data-comparison-header
|
||||||
a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank")
|
a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank")
|
||||||
img.data-comparison-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
img.data-comparison-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", data-color=comparison.Anime.AverageColor(), alt=comparison.Anime.Title.ByUser(user))
|
||||||
|
|
||||||
.data-comparison-title
|
.data-comparison-title
|
||||||
a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical
|
a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical
|
||||||
|
@ -3,7 +3,7 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.Us
|
|||||||
|
|
||||||
.episode-view-image-container
|
.episode-view-image-container
|
||||||
a.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
|||||||
each item in animeList.Items
|
each item in animeList.Items
|
||||||
if item.Status == arn.AnimeListStatusWatching || item.Status == arn.AnimeListStatusCompleted
|
if item.Status == arn.AnimeListStatusWatching || item.Status == arn.AnimeListStatusCompleted
|
||||||
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.ByUser(user) + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.ByUser(user) + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
||||||
img.profile-watching-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", data-color=item.Anime().Image.AverageColor, alt=item.Anime().Title.ByUser(user))
|
img.profile-watching-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", data-color=item.Anime().AverageColor(), alt=item.Anime().Title.ByUser(user))
|
||||||
|
|
||||||
.footer
|
.footer
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -58,4 +58,4 @@ component QuoteTabs(quote *arn.Quote, user *arn.User)
|
|||||||
|
|
||||||
component QuoteAnime(anime *arn.Anime, user *arn.User)
|
component QuoteAnime(anime *arn.Anime, user *arn.User)
|
||||||
a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.quote-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.quote-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
@ -65,7 +65,7 @@ component AnimeSearchResults(animes []*arn.Anime)
|
|||||||
.profile-watching-list.anime-search
|
.profile-watching-list.anime-search
|
||||||
each anime in animes
|
each anime in animes
|
||||||
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
|
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
|
||||||
img.anime-cover-image.anime-search-result.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.Canonical)
|
img.anime-cover-image.anime-search-result.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.Canonical)
|
||||||
|
|
||||||
component CharacterSearchResults(characters []*arn.Character)
|
component CharacterSearchResults(characters []*arn.Character)
|
||||||
if len(characters) == 0
|
if len(characters) == 0
|
||||||
|
@ -26,7 +26,7 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
|
|||||||
.soundtrack-anime-list
|
.soundtrack-anime-list
|
||||||
each anime in track.Anime()
|
each anime in track.Anime()
|
||||||
a.soundtrack-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.soundtrack-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.soundtrack-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.soundtrack-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", data-color=anime.AverageColor(), alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
if len(track.Links) > 0
|
if len(track.Links) > 0
|
||||||
.widget.mountable
|
.widget.mountable
|
||||||
|
@ -38,6 +38,7 @@ export class AnimeNotifier {
|
|||||||
|
|
||||||
elementFound: MutationQueue
|
elementFound: MutationQueue
|
||||||
elementNotFound: MutationQueue
|
elementNotFound: MutationQueue
|
||||||
|
elementColorPreview: MutationQueue
|
||||||
unmount: MutationQueue
|
unmount: MutationQueue
|
||||||
|
|
||||||
constructor(app: Application) {
|
constructor(app: Application) {
|
||||||
@ -48,6 +49,7 @@ export class AnimeNotifier {
|
|||||||
|
|
||||||
this.elementFound = new MutationQueue(elem => elem.classList.add("element-found"))
|
this.elementFound = new MutationQueue(elem => elem.classList.add("element-found"))
|
||||||
this.elementNotFound = new MutationQueue(elem => elem.classList.add("element-not-found"))
|
this.elementNotFound = new MutationQueue(elem => elem.classList.add("element-not-found"))
|
||||||
|
this.elementColorPreview = new MutationQueue(elem => elem.classList.add("element-color-preview"))
|
||||||
this.unmount = new MutationQueue(elem => elem.classList.remove("mounted"))
|
this.unmount = new MutationQueue(elem => elem.classList.remove("mounted"))
|
||||||
|
|
||||||
// These classes will never be removed on DOM diffs
|
// These classes will never be removed on DOM diffs
|
||||||
@ -538,7 +540,7 @@ export class AnimeNotifier {
|
|||||||
lazyLoadImage(element: HTMLImageElement) {
|
lazyLoadImage(element: HTMLImageElement) {
|
||||||
if(element.dataset.color) {
|
if(element.dataset.color) {
|
||||||
element.style.backgroundColor = element.dataset.color
|
element.style.backgroundColor = element.dataset.color
|
||||||
this.elementFound.queue(element)
|
this.elementColorPreview.queue(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once the image becomes visible, load it
|
// Once the image becomes visible, load it
|
||||||
|
@ -38,6 +38,9 @@ a
|
|||||||
img
|
img
|
||||||
backface-visibility hidden
|
backface-visibility hidden
|
||||||
|
|
||||||
|
// Hide the alt text that is shown while the image is loading
|
||||||
|
// text-indent -9999px
|
||||||
|
|
||||||
.hidden
|
.hidden
|
||||||
display none !important
|
display none !important
|
||||||
|
|
||||||
|
@ -2,10 +2,18 @@
|
|||||||
visibility hidden
|
visibility hidden
|
||||||
opacity 0
|
opacity 0
|
||||||
|
|
||||||
|
.element-color-preview
|
||||||
|
visibility visible
|
||||||
|
animation color-preview 1000ms forwards
|
||||||
|
|
||||||
|
animation color-preview
|
||||||
|
100%
|
||||||
|
opacity 1
|
||||||
|
|
||||||
.element-found
|
.element-found
|
||||||
visibility visible
|
visibility visible
|
||||||
opacity 1 !important
|
opacity 1
|
||||||
|
|
||||||
.element-not-found
|
.element-not-found
|
||||||
visibility hidden
|
visibility hidden
|
||||||
opacity 0 !important
|
opacity 0
|
Loading…
Reference in New Issue
Block a user