Если это слишком быстро, просто увеличьте время до fadeOut()
и fadeIn()
. Используйте $(window).focus()
и $(window).blur()
, чтобы проверить, когда пользователь покинул вкладку и очистит интервал слайд-шоу. Когда пользователь вернется, снова установите интервал.
$("#slideshow > div:gt(0)").hide();
var slideshow = setInterval(function() {
beginSlideshow();
}, 5000);
function beginSlideshow(){
$('#slideshow > div:first')
.fadeOut(2000)//time doubled from 1000 to 2000 milliseconds
.next()
.fadeIn(2000)//time doubled from 1000 to 2000 milliseconds
.end()
.appendTo('#slideshow');
}
$(window).focus(function() {
if (slideshow==null){
//Use came back to the tab
slideshow = setInterval(function(){
beginSlideshow();
}, 5000);
}
});
$(window).blur(function() {
//User left tab
clearInterval(slideshow);
slideshow = null;
});
JSFiddle: http://jsfiddle.net / 1vk3fqr8 / 3 /
Быстрый Ответ : при замене использования leftJoin только с соединением (или innerJoin) тогда, Вы получите то, что Вы хотите: только Сообщения, которые имеют по крайней мере 1 фотографию.
Детали
, Если Вы смотрите на это полезное ТАК Q& A:
Методы Соединения MySQL Different
... Вы найдете некоторые превосходные схемы Венна, показывающие различие между левым и внутренним объединением. Затем при изучении класса Доктрины Doctrine\ORM\QueryBuilder Вы найдете, что у них есть три метода соединения:
/**
* Creates and adds a join over an entity association to the query.
*
* The entities in the joined association will be fetched as part of the query
* result if the alias used for the joined association is placed in the select
* expressions.
*
* <code>
* $qb = $em->createQueryBuilder()
* ->select('u')
* ->from('User', 'u')
* ->join('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
* </code>
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
*
* @return self
*/
public function join($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
{
return $this->innerJoin($join, $alias, $conditionType, $condition, $indexBy);
}
/**
* Creates and adds a join over an entity association to the query.
*
* The entities in the joined association will be fetched as part of the query
* result if the alias used for the joined association is placed in the select
* expressions.
*
* [php]
* $qb = $em->createQueryBuilder()
* ->select('u')
* ->from('User', 'u')
* ->innerJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
*
* @return self
*/
public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
{
$parentAlias = substr($join, 0, strpos($join, '.'));
$rootAlias = $this->findRootAlias($alias, $parentAlias);
$join = new Expr\Join(
Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition, $indexBy
);
return $this->add('join', [$rootAlias => $join], true);
}
/**
* Creates and adds a left join over an entity association to the query.
*
* The entities in the joined association will be fetched as part of the query
* result if the alias used for the joined association is placed in the select
* expressions.
*
* <code>
* $qb = $em->createQueryBuilder()
* ->select('u')
* ->from('User', 'u')
* ->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1');
* </code>
*
* @param string $join The relationship to join.
* @param string $alias The alias of the join.
* @param string|null $conditionType The condition type constant. Either ON or WITH.
* @param string|null $condition The condition for the join.
* @param string|null $indexBy The index for the join.
*
* @return self
*/
public function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
{
$parentAlias = substr($join, 0, strpos($join, '.'));
$rootAlias = $this->findRootAlias($alias, $parentAlias);
$join = new Expr\Join(
Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition, $indexBy
);
return $this->add('join', [$rootAlias => $join], true);
}
, Изменяющий Ваш код, чтобы использовать innerJoin (или просто присоединиться), приведет Доктрину выпускать ВНУТРЕННЕЕ ОБЪЕДИНЕНИЕ в сгенерированном SQL, который возвратит только записи, где "что-то" существует с обеих сторон соединения, таким образом любое Сообщение, которое не имеет никаких фотографий, не будет включено в результаты.