我使用ion-scroll
编写了水平图像滑块的代码。它运作正常。但我希望我的页面也可以垂直滚动。
我无法通过滑动<ion-scroll>
(图片中标记的区域)内的内容来滚动整个页面。但我可以通过在标记区域外滑动来滚动页面。如果我更改了direction="xy"
,那么我只能在<ion-scroll>
内容中滚动。
<ion-content>
<ion-scroll zooming="false" direction="x" style="width: 100%;">
<div style="width: {{albumDetail.sliderWidth}}; repeat">
<span ng-repeat="list in albumDetail.lists">
<a href="#/app/browse/albums/{{albumDetail.type}}/{{list.id}}"><button id="album-card" class="button button-light">
<img width="140px" height="140px" src="{{list.albumArt}}"/>
<p id="album-name-card">{{list.albumName}}</p>
</button></a>
</span>
</div>
</ion-scroll>
</ion-content>
答案 0 :(得分:2)
所以这是一个长期存在的问题,有一种方法可以让它工作但是它有很多代码:我将在这里发布并给出codepen的链接
HTML:
body {
cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
ion-scroll {
width: 100%;
font-size: 40px;
height: auto;
white-space: nowrap;
padding: 10px;
line-height: 40px;
}
CSS:
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope, $ionicScrollDelegate, $timeout) {
$timeout(function(){
//return false; // <--- comment this to "fix" the problem
var sv = $ionicScrollDelegate.$getByHandle('horizontal').getScrollView();
var container = sv.__container;
var originaltouchStart = sv.touchStart;
var originalmouseDown = sv.mouseDown;
var originaltouchMove = sv.touchMove;
var originalmouseMove = sv.mouseMove;
container.removeEventListener('touchstart', sv.touchStart);
container.removeEventListener('mousedown', sv.mouseDown);
document.removeEventListener('touchmove', sv.touchMove);
document.removeEventListener('mousemove', sv.mousemove);
sv.touchStart = function(e) {
e.preventDefault = function(){}
originaltouchStart.apply(sv, [e]);
}
sv.touchMove = function(e) {
e.preventDefault = function(){}
originaltouchMove.apply(sv, [e]);
}
sv.mouseDown = function(e) {
e.preventDefault = function(){}
originalmouseDown.apply(sv, [e]);
}
sv.mouseMove = function(e) {
e.preventDefault = function(){}
originalmouseMove.apply(sv, [e]);
}
container.addEventListener("touchstart", sv.touchStart, false);
container.addEventListener("mousedown", sv.mouseDown, false);
document.addEventListener("touchmove", sv.touchMove, false);
document.addEventListener("mousemove", sv.mouseMove, false);
});
$timeout(function(){
//return false; // <--- comment this to "fix" the problem
var sv = $ionicScrollDelegate.$getByHandle('horizontal2').getScrollView();
var container = sv.__container;
var originaltouchStart = sv.touchStart;
var originalmouseDown = sv.mouseDown;
var originaltouchMove = sv.touchMove;
var originalmouseMove = sv.mouseMove;
container.removeEventListener('touchstart', sv.touchStart);
container.removeEventListener('mousedown', sv.mouseDown);
document.removeEventListener('touchmove', sv.touchMove);
document.removeEventListener('mousemove', sv.mousemove);
sv.touchStart = function(e) {
e.preventDefault = function(){}
originaltouchStart.apply(sv, [e]);
}
sv.touchMove = function(e) {
e.preventDefault = function(){}
originaltouchMove.apply(sv, [e]);
}
sv.mouseDown = function(e) {
e.preventDefault = function(){}
originalmouseDown.apply(sv, [e]);
}
sv.mouseMove = function(e) {
e.preventDefault = function(){}
originalmouseMove.apply(sv, [e]);
}
container.addEventListener("touchstart", sv.touchStart, false);
container.addEventListener("mousedown", sv.mouseDown, false);
document.addEventListener("touchmove", sv.touchMove, false);
document.addEventListener("mousemove", sv.mouseMove, false);
});
});
// Scroll fix directive
(function() {
var HorizontalScrollFix = (function() {
function HorizontalScrollFix($timeout, $ionicScrollDelegate) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var mainScrollID = attrs.horizontalScrollFix,
scrollID = attrs.delegateHandle;
var getEventTouches = function(e) {
return e.touches && (e.touches.length ? e.touches : [
{
pageX: e.pageX,
pageY: e.pageY
}
]);
};
var fixHorizontalAndVerticalScroll = function() {
var mainScroll, scroll;
mainScroll = $ionicScrollDelegate.$getByHandle(mainScrollID).getScrollView();
scroll = $ionicScrollDelegate.$getByHandle(scrollID).getScrollView();
// patch touchstart
scroll.__container.removeEventListener('touchstart', scroll.touchStart);
scroll.touchStart = function(e) {
var startY;
scroll.startCoordinates = ionic.tap.pointerCoord(e);
if (ionic.tap.ignoreScrollStart(e)) {
return;
}
scroll.__isDown = true;
if (ionic.tap.containsOrIsTextInput(e.target) || e.target.tagName === 'SELECT') {
scroll.__hasStarted = false;
return;
}
scroll.__isSelectable = true;
scroll.__enableScrollY = true;
scroll.__hasStarted = true;
scroll.doTouchStart(getEventTouches(e), e.timeStamp);
startY = mainScroll.__scrollTop;
// below is our changes to this method
// e.preventDefault();
// lock main scroll if scrolling horizontal
$timeout((function() {
var animate, yMovement;
yMovement = startY - mainScroll.__scrollTop;
if (scroll.__isDragging && yMovement < 2.0 && yMovement > -2.0) {
mainScroll.__isTracking = false;
mainScroll.doTouchEnd();
animate = false;
return mainScroll.scrollTo(0, startY, animate);
} else {
return scroll.doTouchEnd();
}
}), 100);
};
scroll.__container.addEventListener('touchstart', scroll.touchStart);
};
$timeout(function() { fixHorizontalAndVerticalScroll(); });
}
};
}
return HorizontalScrollFix;
})();
angular.module('ionicApp').directive('horizontalScrollFix', ['$timeout', '$ionicScrollDelegate', HorizontalScrollFix]);
}).call(this);
JS:
Private Sub List0_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
For Each varItem In Me!lstProduct.ItemsSelected
strCriteria = strCriteria & ",'" & Me!lstProduct.ItemData(varItem) & "'"
Next varItem
If Len(strCriteria) = 0 Then
MsgBox "You did not select anything from the list" _
, vbExclamation, "Nothing to find!"
Exit Sub
End If
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
strSQL = "SELECT * FROM ProductTable " & _
"WHERE ProductTable.ID IN(" & strCriteria & ");"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryMultiSelect"
Set db = Nothing
Set qdf = Nothing
End Sub