Commit f1ea0484 authored by wangqinghua's avatar wangqinghua

左滑

parent 65b65be3
import { NgModule } from '@angular/core'; import {NgModule} from '@angular/core';
import { SlideComponent } from './slide/slide'; import {SlideComponent} from './slide/slide';
import {IonicPageModule} from "ionic-angular"; import {IonicPageModule} from "ionic-angular";
import { SlideListComponent } from './slide-list/slide-list'; import {SlideListComponent} from './slide-list/slide-list';
@NgModule({ @NgModule({
declarations: [SlideComponent, declarations: [SlideComponent,
SlideListComponent, SlideListComponent,
...@@ -12,10 +13,11 @@ import { SlideListComponent } from './slide-list/slide-list'; ...@@ -12,10 +13,11 @@ import { SlideListComponent } from './slide-list/slide-list';
], ],
exports: [SlideComponent, exports: [SlideComponent,
SlideListComponent, SlideListComponent,
], ],
providers:[ providers: [
SlideComponent, SlideComponent,
SlideListComponent,
] ]
}) })
export class ComponentsModule {} export class ComponentsModule {
}
<!--true 隐藏 false 显示-->
<div [hidden]="isScroll" class="news-content"> <div [hidden]="isScroll" class="news-content">
<div class="tabs-parent"> <div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children"> <div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
...@@ -7,6 +8,7 @@ ...@@ -7,6 +8,7 @@
</div> </div>
</div> </div>
<!--固定 false -->
<div [hidden]="!isScroll" ion-fixed class="news-content ion-fixed"> <div [hidden]="!isScroll" ion-fixed class="news-content ion-fixed">
<div class="tabs-parent"> <div class="tabs-parent">
<div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children"> <div *ngFor="let item of tabsList;let i = index" (click)="change(item)" class="tabs-children">
......
import {AfterViewInit, Component, ElementRef, ViewChild} from '@angular/core'; import {AfterViewInit, Component, ElementRef, NgZone, ViewChild} from '@angular/core';
import {Slides} from "ionic-angular"; import {Content, Slides} from "ionic-angular";
import {TabsService} from "../../pages/tabs/tabs.service"; import {TabsService} from "../../pages/tabs/tabs.service";
import {AppGlobal} from "../../service/http.service"; import {AppGlobal} from "../../service/http.service";
...@@ -7,11 +7,11 @@ import {AppGlobal} from "../../service/http.service"; ...@@ -7,11 +7,11 @@ import {AppGlobal} from "../../service/http.service";
selector: 'slide-list', selector: 'slide-list',
templateUrl: 'slide-list.html' templateUrl: 'slide-list.html'
}) })
export class SlideListComponent implements AfterViewInit{ export class SlideListComponent implements AfterViewInit {
@ViewChild(Slides) slides:Slides; @ViewChild(Slides) slides1: Slides;
@ViewChild('tabSpan') tabSpan:ElementRef; @ViewChild('tabSpan') tabSpan: ElementRef;
@ViewChild('tips') tips:ElementRef; @ViewChild('tips') tips: ElementRef;
@ViewChild('tips1') tips1:ElementRef; @ViewChild('tips1') tips1: ElementRef;
isScroll = false; isScroll = false;
//所属板块类型: //所属板块类型:
...@@ -28,10 +28,8 @@ export class SlideListComponent implements AfterViewInit{ ...@@ -28,10 +28,8 @@ export class SlideListComponent implements AfterViewInit{
picture: string = AppGlobal.domain + '/wisdomgroup'; picture: string = AppGlobal.domain + '/wisdomgroup';
constructor(private tabsSer: TabsService,public zone:NgZone) {
constructor(private tabsSer:TabsService) {
this.slideList.length = 4; this.slideList.length = 4;
console.log('Hello SlideListComponent Component');
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
...@@ -64,19 +62,25 @@ export class SlideListComponent implements AfterViewInit{ ...@@ -64,19 +62,25 @@ export class SlideListComponent implements AfterViewInit{
e.imgUrl = e.attachments[0].path; e.imgUrl = e.attachments[0].path;
} }
}) })
this.slides.slideTo(index,500); this.slides1.slideTo(index, 500);
this.slideList[index] = arr; this.slideList[index] = arr;
} }
) )
} }
slideChange(e){ slideChange(e) {
const index = this.slides.getActiveIndex(); const index = this.slides1.getActiveIndex();
// console.log(this.tabsList[index]); this.change(this.tabsList[index])
// this.changeParent(this.tabsList[index]) }
//判断是否scroll true 滑动 false 不滑动
scroll(bool) {
this.isScroll = bool !== 'false';
console.log(this.isScroll)
} }
// //
goToDetail(item){} goToDetail(item) {
}
} }
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
</ion-slide> </ion-slide>
</ion-slides> </ion-slides>
</div> </div>
<p class="slides-title">{{slideTitle}} <span class="main-color" float-end>1<span <p class="slides-title">
{{slideTitle}} <span class="main-color" float-end>1<span
style="font-size: 1.5rem;font-weight: 400;">/{{slidersItems.length}}</span></span></p> style="font-size: 1.5rem;font-weight: 400;">/{{slidersItems.length}}</span></span></p>
\ No newline at end of file
...@@ -12,6 +12,7 @@ import {SearchNewPage} from "../../home-pages/search-new/search-new"; ...@@ -12,6 +12,7 @@ import {SearchNewPage} from "../../home-pages/search-new/search-new";
import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail"; import {StuffDetailPage} from "../../home-pages/stuff-detail/stuff-detail";
import {EmitService} from "../../../provide/emit.service"; import {EmitService} from "../../../provide/emit.service";
import {DatePipe} from "@angular/common"; import {DatePipe} from "@angular/common";
import {SlideListComponent} from "../../../components/slide-list/slide-list";
@IonicPage() @IonicPage()
@Component({ @Component({
...@@ -61,7 +62,7 @@ export class HomePage { ...@@ -61,7 +62,7 @@ export class HomePage {
constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe, constructor(public navCtrl: NavController, public tts: TextToSpeech, public datePipe: DatePipe,
public commonSer: CommonService, public emitSer: EmitService, public commonSer: CommonService, public emitSer: EmitService,
public zone: NgZone,public renderer:Renderer2, public zone: NgZone,public slideList:SlideListComponent,
public appService: AppService, public http: Http, public storage: Storage, public appService: AppService, public http: Http, public storage: Storage,
public badge: Badge, public tabsSer: TabsService) { public badge: Badge, public tabsSer: TabsService) {
// 接收发射过来的数据 // 接收发射过来的数据
...@@ -85,15 +86,17 @@ export class HomePage { ...@@ -85,15 +86,17 @@ export class HomePage {
this.getInfo(); this.getInfo();
this.scrollHeight(); this.scrollHeight();
} }
scrollHeight(){ scrollHeight(){
const height = this.topHeight.nativeElement.offsetHeight + 80; const height = this.topHeight.nativeElement.offsetHeight + 80;
this.content.ionScroll.subscribe(($event)=>{ this.content.ionScroll.subscribe(($event)=>{
this.zone.run(()=>{ this.zone.run(()=>{
// this.headerTag.nativeElement. // this.headerTag.nativeElement.
if(this.content.scrollTop > height){ if(this.content.scrollTop > height){
this.isScroll = true; this.slideList.scroll('true');
}else{ }else{
this.isScroll = false; this.slideList.scroll('false');
} }
this.content.resize(); this.content.resize();
}) })
......
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